小编use*_*466的帖子

从 python 向带有 windows-1251 编码的页面发送请求

我需要获取页面源代码 (html) 并将其转换为 uft8,因为我想在此页面中找到一些文本(例如,如果 page_source 中的“my_same_text”:则...)。此页面包含俄文文本(?yrillic 符号),以及此标签

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
Run Code Online (Sandbox Code Playgroud)

我使用flask,并请求python lib。我发送请求源 = requests.get('url/')

if '?yrillic symbols' in source.text: ...
Run Code Online (Sandbox Code Playgroud)

我找不到我的文本,这是由于我如何将文本转换为 utf8 的编码?我尝试 .encode() .decode() 但它没有帮助。

python encode utf-8 flask python-requests

1
推荐指数
1
解决办法
6444
查看次数

标签 统计

encode ×1

flask ×1

python ×1

python-requests ×1

utf-8 ×1