网站拒绝无头的镀铬连接

时间:2019-12-26 16:44:05

标签: google-chrome http web-scraping https google-chrome-headless

我正在尝试实现简单的刮板,但是遇到了一些问题。网站不知何故拒绝了无头Chrome的连接。这是第一个也是唯一的请求,没有任何JavaScript执行。普通chrome的请求效果很好,因此绝对不是被禁止的ip。这里有什么问题?他们可能如何检测到它?

我正在运行普通的无头chrome,然后更换用户代理,仅此而已。

.\chrome.exe --headless --remote-debugging-port=9222

General:
  Request URL: https://www.adidas.de/
  Request Method: GET
  Status Code: 403 
  Remote Address: 23.210.248.137:443
  Referrer Policy: no-referrer-when-downgrade

Response Headers:
  cache-control: max-age=0, no-cache, no-store
  content-length: 1952
  content-type: text/html
  date: Thu, 26 Dec 2019 16:16:49 GMT
  expires: Thu, 26 Dec 2019 16:16:49 GMT
  pragma: no-cache
  status: 403

Request Headers:
  :authority: www.adidas.de
  :method: GET
  :path: /
  :scheme: https
  accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
  accept-encoding: gzip, deflate, br
  cache-control: max-age=0
  sec-fetch-mode: navigate
  sec-fetch-site: none
  sec-fetch-user: ?1
  upgrade-insecure-requests: 1
  user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36

1 个答案:

答案 0 :(得分:0)

@RobertHarvey:是的,您是正确的:对于某些网站,必须发送Accept-Language。您可以通过他们的API使用puppeteer进行操作,也可以通过拦截请求并直接添加标头使用chrome-remote接口进行操作。