我想爬一个像这一样的网页。
我好像出了个405错误
2018-04-09 11:18:40.930 c.d.s.b.FetcherBolt FetcherThread #2 [INFO] [Fetcher #3] Fetched https://www.notebooksbilliger.de/lenovo+320+15abr+80xs009bge/incrpc/topprod with status 405 in msec 53
这页似乎有爬虫保护。是否还可以使用风暴爬虫和selenium一起爬行呢?
发布于 2018-04-09 10:52:56
该站点不允许机器人,但如果用户代理看起来不像浏览器,则返回405。你可以用卷发再现这个问题。
curl -A -I "https://www.notebooksbilliger.de/lenovo+320+15abr+80xs009bge"
HTTP/1.1 405 Method Not Allowed
Accept-Ranges: bytes
Content-Type: text/html
Server: nginx
Surrogate-Control: no-store, bypass-cache
X-Distil-CS: BYPASS
Expires: Mon, 09 Apr 2018 10:48:02 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Mon, 09 Apr 2018 10:48:02 GMT
Connection: keep-alive
curl -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" -I "https://www.notebooksbilliger.de/lenovo+320+15abr+80xs009bge"
HTTP/1.1 200 OK
Content-Type: text/html
Server: nginx
Surrogate-Control: no-store, bypass-cache
Expires: Mon, 09 Apr 2018 10:48:26 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Mon, 09 Apr 2018 10:48:26 GMT
Connection: keep-alive
解决办法之一是按照建议使用selenium,或者简单地更改用户代理,使其模拟浏览器将使用的内容。不是很好,因为它总是更好地开放你的爬虫,但在这种特殊情况下,网站将防止爬虫在他们的robots.txt,如果这是他们的意图。
您可以通过StormCrawler中的配置更改用户代理。
https://stackoverflow.com/questions/49729840
复制相似问题