我目前正在尝试使用 Python 中的 Selenium 和 Requests 模块构建一个小型机器人。
但是,我想与之交互的网页在 Cloudflare 后面运行。
我的 python 脚本使用 stem 模块在 Tor 上运行。
我的流量分析基于使用 Persist Logs 的 Firefox 的“开发者选项->网络”。
如果 Cloudflare 正在检查我的 Javascript 功能,我的请求模块不应该返回 503 吗?
driver = webdriver.Firefox(firefox_profile=fp, options=fOptions)
driver.get("https://www.cloudflare.com") # usually returns code 200 without verifying the browser
session = requests.Session()
# ... applied socks5 proxy for both http and https ... #
session.headers.update({"user-agent": driver.execute_script("return navigator.userAgent;")})
page = session.get("https://www.cloudflare.com")
print(page.status_code) # return …Run Code Online (Sandbox Code Playgroud)