How to avoid redirection of the webcrawler to the

2019-07-31 22:58发布

I subclassed a CrawlSpider and want to extract data from website. However, I always get redirected to the site's mobile version. I tried to change the USER_AGENT variable in scrapy's settings to Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1, but still get redirected.

Is there another way to signal another client and avoid redirection?

1条回答
冷血范
2楼-- · 2019-07-31 23:27

There are two types of redirection supported in Scrapy:

  • RedirectMiddleware - Handle redirection of requests based on response status
  • MetaRefreshMiddleware - Handle redirection of requests based on meta-refresh html tag

So, maybe your html page uses second type of redirection?

See also:

查看更多
登录 后发表回答