Is it normal to return errorcode:50, when crawling Youdao Translation using scrapy? is it normal to use requests?

when crawling Youdao Translation with scrapy, it is normal to return errorcode:50, with requests.

    def get_result(self):
        """headers"""
        headers = {
            "referer": "https://www.baidu.com/",
            "cookie": "OUTFOX_SEARCH_USER_ID=-2022895048@10.168.8.76;",
            "user-agent": "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Mobile Safari/537.36",
        }
        data = {"i": "hello",
                "from": "AUTO",
                "to": "AUTO",
                "smartresult": "dict",
                "client": "fanyideskweb",
                "salt": "1523323753717",
                "sign": "e9243107c4256bef73cd95bef15006e0",
                "doctype": "json",
                "version": "2.1",
                "keyfrom": "fanyi.web",
                "action": "FY_BY_CL1CKBUTTON",
                "typoResult": "true"}
        html = requests.post(self.url, data=data, headers=headers).text
        print(html)
        infos = json.loads(html)
        if "translateResult" in infos:
            try:
                result = infos["translateResult"][0][0]["tgt"]
                print(result)
            except:
                pass

the above is in requests mode, and the code is copied from fish C. I wrote the data part of it for analysis, and the translation result can be obtained. The result is as follows


scrapyheaderdataerrorcode:50

.

is a rookie who doesn"t understand and hasn"t started yet to ask for advice

Mar.02,2021

No one answered.

Menu