spider_ use request parameter passing library post

# from urllib import parse,request
# import json
import requests

# 有道翻译url
url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"
# post的参数
parameter = {
"i":"hello",
"from":"AUTO",
"to":"AUTO",
"smartresult":"dict",
"client":"fanyideskweb",
"salt":"15577378774445",
"sign":"44163461e046a197ba4681e91aa49524",
"ts":"1557737877444",
"bv":"e2a78ed30c66e16a857c5b6486a1d326",
"doctype":"json" , "Version": "2.1" , "keyfrom": "fanyi.web" , "Action": "FY_BY_REALTlME" , } # get is json string, string objects into python dict, list = requests.post pythonObj (URL , Data = Parameter) .json () Print (pythonObj) Print ( type (pythonObj)) # by index taking the result Print (pythonObj [ "translateResult"] [ 0] [ 0] [ "TGT" ])










Guess you like

Origin www.cnblogs.com/YangQingHong/p/10978276.html