编写爬虫使用百度翻译遇到这种情况

#_*_coding:utf-8_*_
import requests
url = "http://fanyi.baidu.com/v2transapi"
data = {"from":"zh","to":"en","query":"你好世界",
"transtype":"translang",
"simple_means_flag":"3",
"sign":"289133.35420",
"token":"7f110b62804d2d37b65cc43f2859bdd3"}
headers={"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
         "Referer":"http://fanyi.baidu.com/?aldtype=16047"}
response = requests.post(url,data = data,headers = headers)
print(response)


print(response.content.decode())

这是代码,但是爬取下来的query对应的值不是utf-8编码

你可能感兴趣的:(编写爬虫使用百度翻译遇到这种情况)