当前位置 博文首页 > S_zhangmin的博客:简单爬虫 post篇

    S_zhangmin的博客:简单爬虫 post篇

    作者:[db:作者] 时间:2021-09-19 16:15

    import requests
    import json
    def get_translate(word=None):
    ? ? url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"
    ? ? Form_data = {'i': word,
    ? ? 'from': 'AUTO',
    ? ? 'to': 'AUTO',
    ? ? 'smartresult': 'dict',
    ? ? 'client': 'fanyideskweb',
    ? ? 'salt': '1537420260222',
    ? ? 'sign': 'd7d2646a06bd528315bd23e0c5718aab',
    ? ? 'doctype': 'json',
    ? ? 'version': '2.1',
    ? ? 'keyfrom': 'fanyi.web',
    ? ? 'action':' FY_BY_REALTIME',
    ? ? 'typoResult': 'false'}
    ? ? response = requests.post(url,data = Form_data)
    ? ? content = json.loads(response.text)
    ? ? print('输入:'+content['translateResult'][0][0]['src']+'\n'+ '翻译:' + content['translateResult'][0][0]['tgt'])

    cs