当前位置:网站首页>Scratch returns 400

Scratch returns 400

2022-06-26 03:01:00 0 & 1 dishes

  • scene
    Use scrapy Capture data , The parameters to be passed are Request Payload Parameters , Use Resquest send out post request
  • The code is as follows
    This is to return 400 Code for
yield scrapy.Request(url=url,
             method="POST",
             headers={
    "Content-Type":"application/json","Host":"web.hi-teeth.com","Content-Length":"18"},
             encoding="utf-8",
             body=json.dumps({
    "key":"value"}),
             dont_filter=True,
             callback= Callback function )
  • reason
    In the header information "Content-Length":"18" Error message caused by , Just cancel it , Personal tasks may be limited to 18 Error causing insufficient length

  • Solution
    Remove... From the header message "Content-Length" that will do

Correct code

yield scrapy.Request(url=url,
             method="POST",
             headers={
    "Content-Type":"application/json","Host":"web.hi-teeth.com"},
             encoding="utf-8",
             body=json.dumps({
    "key":"value"}),
             dont_filter=True,
             callback= Callback function )

There are students who know the right reasons to give guidance , Thank you very much

原网站

版权声明
本文为[0 & 1 dishes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260219290454.html