Ati*_*k R 5 selenium google-chrome web-scraping python-3.x selenium-chromedriver
我正在尝试在 python 中使用 selenium 构建一个刮刀。Selenium Webdriver 打开窗口并尝试加载页面但突然停止加载。我可以在本地 Chrome 浏览器中访问相同的链接。
以下是我从网络驱动程序获得的错误日志:
{'level': 'SEVERE', 'message': 'https://shop.coles.com.au/a/a-nsw-metro-rouse-hill/everything/browse/baby/nappies-changing?pageNumber=1 - Failed to load resource: the server responded with a status of 429 (Too Many Requests)', 'source': 'network', 'timestamp': 1556997743637}
{'level': 'SEVERE', 'message': 'about:blank - Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME', 'source': 'network', 'timestamp': 1556997745338}
{'level': 'SEVERE', 'message': 'https://shop.coles.com.au/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/fingerprint - Failed to load resource: the server responded with a status of 404 (Not Found)', 'source': 'network', 'timestamp': 1556997748339}
Run Code Online (Sandbox Code Playgroud)
我的脚本:
from selenium import webdriver
import os
path = os.path.join(os.getcwd(), 'chromedriver')
driver = webdriver.Chrome(executable_path=path)
links = [
"https://shop.coles.com.au/a/a-nsw-metro-rouse-hill/everything/browse/baby/nappies-changing?pageNumber=1",
"https://shop.coles.com.au/a/a-nsw-metro-rouse-hill/everything/browse/baby/baby-accessories?pageNumber=1",
"https://shop.coles.com.au/a/a-nsw-metro-rouse-hill/everything/browse/baby/food?pageNumber=1",
"https://shop.coles.com.au/a/a-nsw-metro-rouse-hill/everything/browse/baby/formula?pageNumber=1",
]
for link in links:
driver.get(link)
Run Code Online (Sandbox Code Playgroud)
HTTP 429 Too Many Requests响应状态代码表示用户在给定时间内发送了太多请求(“速率限制”)。响应表示应该包括解释条件的详细信息,并且可以包括Retry-After指示在发出新请求之前等待多长时间的标头。
当服务器受到攻击或刚刚收到来自一方的大量请求时,用429状态代码响应每个请求将消耗资源。因此,服务器不需要使用429状态码;当限制资源使用时,仅删除连接或采取其他步骤可能更合适。
HTTP 404 Not Found客户端错误响应代码表示服务器找不到所请求的资源。在浏览器中,这意味着该 URL 无法识别。在 API 中,这也可能意味着端点有效但资源本身不存在。服务器还可以发送此响应而不是 403,以向未经授权的客户端隐藏资源的存在。由于该响应代码在网络上频繁出现,因此可能是最著名的响应代码。
状态代码404并不指示资源是暂时丢失还是永久丢失。但如果资源被永久删除,410 (Gone)则应使用 a 而不是404状态。此外,404当未找到所请求的资源时,将使用状态代码,无论该资源是否不存在,或者出于401安全403原因,服务想要屏蔽该资源。
当我尝试你的代码块时,我遇到了类似的后果。如果你检查网页的DOM 树,你会发现很多标签都带有关键字dist。举个例子:
<link rel="shortcut icon" type="image/x-icon" href="/wcsstore/ColesResponsiveStorefrontAssetStore/dist/30e70cfc76bf73d384beffa80ba6cbee/img/favicon.ico"><link rel="stylesheet" href="/wcsstore/ColesResponsiveStorefrontAssetStore/dist/30e70cfc76bf73d384beffa80ba6cbee/css/google/fonts-Source-Sans-Pro.css" type="text/css" media="screen">'appDir': '/wcsstore/ColesResponsiveStorefrontAssetStore/dist/30e70cfc76bf73d384beffa80ba6cbee/app'术语dist的存在清楚地表明该网站受到Bot 管理服务提供商Distil Networks的保护,并且ChromeDriver的导航会被检测到并随后被阻止。
Distil 通过观察网站行为并识别抓取工具特有的模式来保护网站免受自动内容抓取机器人的侵害。当 Distil 在一个站点上识别出恶意机器人时,它会创建一份部署到所有客户的黑名单行为配置文件。Distil 类似于机器人防火墙,可以检测模式并做出反应。
更远,
"One pattern with **Selenium** was automating the theft of Web content"Distil 首席执行官 Rami Essaid 上周在接受采访时表示。"Even though they can create new bots, we figured out a way to identify Selenium the a tool they're using, so we're blocking Selenium no matter how many times they iterate on that bot. We're doing that now with Python and a lot of different technologies. Once we see a pattern emerge from one type of bot, then we work to reverse engineer the technology they use and identify it as malicious".
您可以在以下位置找到一些详细的讨论:
| 归档时间: |
|
| 查看次数: |
29065 次 |
| 最近记录: |