Scrappy response different than browser response

做~自己de王妃 提交于 2019-12-02 11:06:05

问题


I am trying to scrape a this page with scrapy:

http://www.barnesandnoble.com/s?dref=4815&sort=SA&startat=7391

and the response which I get is different than what I see in the browser. Browser response has the correct page, while scrapy response is:

http://www.barnesandnoble.com/s?dref=4815&sort=SA&startat=1

page. I have tried with urllib2 but still have the same issue. Any help is much appreciated.


回答1:


I don't really understand the issue, but usually a different response for a browser and scrapy is caused by one these:

  • the server analyzes your User-Agent header, and returns a specially crafted page for mobile clients or bots;
  • the server analyzes the cookies, and does something special when it looks like you are visiting for the first time;
  • you are trying to make a POST request via scrapy like the browser does, but you forgot some form fields, or put wrong values
  • etc.

There is no universal way to determine what's wrong, because it depends on the server logic, which you don't know. If you are lucky, you will analyze and fix all the mentioned issues and will make it work.



来源:https://stackoverflow.com/questions/13834736/scrappy-response-different-than-browser-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!