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

Python crawler returns 403 error solution

伊谢尔伦
Release: 2017-04-29 10:05:50
Original
6495 people have browsed it

Question

When crawling data, usually the debugging information is:

DEBUG: Crawled (200) <GET //m.sbmmt.com/> (referer: None)
Copy after login

If

DEBUG: Crawled (403) <GET //m.sbmmt.com/> (referer: None)
Copy after login

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={&#39;User-Agent&#39;: "your agent string"})
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template