54讲的爬虫问题求助
import urllib.requestimport urllib.parse
url = ("https://fanyi.baidu.com/v2transapi?from=en&to=zh")
data = {}
data['from']='en'
data['to']='zh'
data['query']='I love fishc'
data['simple_means_flag']='3'
data['sign']='359143.104918'
data['token']='961fd18df963800cf4a242146c6083e0'
data['domain']='common'
data = urllib.parse.urlencode(data).encode('utf-8')
res = urllib.request.urlopen(url,data)
html = res.read().decode('utf-8')
print(html)
为什么打印出来是这样的 想不明白啊根本没翻译出来{:10_266:}
{"errno":997,"errmsg":"\u672a\u77e5\u9519\u8bef","query":"I love fishc","from":"en","to":"zh","error":997} 我搞百度翻译也是这样,还是有道吧{:10_266:}
感觉得用正则表达式 楼主将你最后一句代码print(html)改成print(eval(html))试试看 因为现在的百度翻译接口和当时录视频时的接口不一样了,肯定升级了,需要重新分析 \u672a\u77e5\u9519\u8bef
转成中文就是未知错误
百度翻译早就做了反扒了 ,记得我当时加了个ua就可以了 qq1151985918 发表于 2020-12-17 21:05
楼主将你最后一句代码改成试试看
还是没用
{'errno': 997, 'errmsg': '未知错误', 'query': 'I love fishc', 'from': 'en', 'to': 'zh', 'error': 997} 反爬了,换有道吧
页:
[1]