Home>Article>Backend Development> Python crawler returns 403 error solution

Python crawler returns 403 error solution

伊谢尔伦
伊谢尔伦 Original
2017-04-29 10:05:50 6393browse

Question

When crawling data, usually the debugging information is:

DEBUG: Crawled (200)  (referer: None)

If

DEBUG: Crawled (403)  (referer: None)

appears, it means that the website uses anti-web-crawling technique ( Used by Amazon), it is relatively simple to check the user agent (User Agent) information.

Solution

Construct a User Agent in the request header, as shown below:

def start_requests(self): yield Request("//m.sbmmt.com/", headers={'User-Agent': "your agent string"})


The above is the detailed content of Python crawler returns 403 error solution. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn