小编Ous*_*azi的帖子

为什么 Instagram 不能与 Selenium headless Chrome 一起使用?

我正在尝试构建一个无头工作的 insta 机器人,但它似乎找不到用户名、密码列(即 NoSuchElementException)。

我尝试运行此代码来排除故障。(基本上打开ig主页并截图)

from selenium import webdriver
from time import sleep

options = webdriver.ChromeOptions()
options.headless = True
options.add_argument("--window-size=1920,1080")
browser = webdriver.Chrome(options=options)
browser.get("https://www.instagram.com")
browser.get_screenshot_as_file(f"screenshot.png")
Run Code Online (Sandbox Code Playgroud)

我得到的这些屏幕截图基本上用法语说“错误,几分钟后重试”

我尝试通过 selenium 找到“connectez-vous”按钮,但是我尝试的每个 xpath 都不起作用,而且不可能通过 f12 找到它

该机器人稍后将上传到 pythonanywhere,以便我可以在云中运行它(所以如果您认为我可能遇到其他问题,您可以告诉我)

你建议我做什么?

python selenium headless selenium-chromedriver pythonanywhere

3
推荐指数
1
解决办法
3058
查看次数