带有 http 405 代码的页面的 Stormcrawler 解决方法
Stormcrawler workaround for pages with http 405 code
我想抓取类似 this 的网页。
我好像遇到了 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
该页面似乎有爬虫保护。是否仍然可以使用 stormcrawler 和 selenium 一起抓取它?
该网站不禁止机器人,但 returns 如果用户代理看起来不像浏览器,则返回 405。您可以使用 curl
重现该问题
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 中的配置更改用户代理。
我想抓取类似 this 的网页。
我好像遇到了 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
该页面似乎有爬虫保护。是否仍然可以使用 stormcrawler 和 selenium 一起抓取它?
该网站不禁止机器人,但 returns 如果用户代理看起来不像浏览器,则返回 405。您可以使用 curl
重现该问题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 中的配置更改用户代理。