有道翻译爬虫实现
POST请求:
#有道翻译爬虫from urllib import request
import urllib
import re#构造请求头信息
header={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) \
Chrome/81.0.4044.122 Safari/537.36"
}#谷歌浏览器#http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule 网页上的url
url="http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"key="白金之星,世界"
#发送到web服务器的表单数据
formdata={
"i":key,
"from":"AUTO",
"to":"AUTO",
"smartresult":"dict",
"client":"fanyideskweb",
"salt":"15880563488791",
"sign":"cc2c40d740538fc5edc0380891faef27",
"ts":"1588053583943",
"bv":"f9c86b1fdf2f53c1fefaef343285247b",
"doctype":"json",
"version":"2.1",
"keyfrom":