求助: selenium chrome 模拟真实请求 DHL 跟踪数据返回 Access Denied 怎么破?使用随机代理+随机 UA 仍然不行

2021-12-03 10:24:36 +08:00
 yasea
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-gpu')# win 必须使用该选项
chrome_options.add_argument('log-level=2')#屏蔽日志
chrome_options.add_argument('--disable-software-rasterizer')
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument('--disable-logging')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--window-size=1220,800")
chrome_options.add_argument('user-agent=' + spider_utils.get_ua())
chrome_options.add_argument('--proxy-server={0}'.format(proxy_ip))
prefs = {
'profile.default_content_setting_values' : {
'notifications' : 2
}
}
chrome_options.add_experimental_option('prefs',prefs)
前几个月是能正常工作的, 最近不好使了, 有经验的朋友,请帮忙瞅瞅
1530 次点击
所在节点    Python
7 条回复
yasea
2021-12-03 11:02:44 +08:00
补充一下,写爬虫的主要目的是对物流单号的 DHL 跟踪数据批量截图保存,因为官方只支持查询近 3 个月的数据。
dicc
2021-12-03 11:57:40 +08:00
add_argument data-dir 这个目录指向你 chrome 真实的数据目录
yasea
2021-12-03 13:24:55 +08:00
@dicc 谢谢,中午测试了下, 依然被反爬了,有时候返回 Access Denied , 有时候返回这个:
Your tracking attempt has been blocked
Please note that the tracking status information on this website is intended for human consumption via the website only. It is not intended to be used for integration with your systems. Automated extraction of information by bots, website scraping etc. is prohibited.
dicc
2021-12-13 09:36:00 +08:00
兄弟,试试这个思路,我用这个思路绕过了一个网站.

https://www[.]cnblogs.com/lovealways/p/9813059.html

相当于它在启动的时候,是以用户的方式启动.但是后续可以用程序控制
yasea
2021-12-13 17:59:02 +08:00
@dicc 谢谢啦,新思路比较有启发, 我尽快试试看
janda
2021-12-15 15:29:27 +08:00
这个可以试试看
# 禁止网站识别自动化
chrome_options.add_argument('disable-blink-features=AutomationControlled')

自己可以在浏览器 console 打印下:window.navigator.webdriver
正常浏览器返回的 false 、chromedrive 的浏览器会是 true
yasea
2022-01-14 22:25:53 +08:00
@janda 谢谢老铁,也不好使, 反爬机制不太好突破了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/819727

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX