python - 使用 selenium 和 chromedriver 无法在 Heroku 上加载 Instagram 登录页面
问题描述
我正在尝试使用 selenium 和 chromedriver 登录 Instagram。驱动程序能够打开登录页面并输入用户名和密码,并且在我的本地 macOS 机器上登录成功。但是当我将它部署到 Heroku 时,它在用户名字段上显示 NoSuchElement。
这是我的代码。
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-agent=Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:17.0) Gecko/20100101 Firefox/17.0")
driver_path = ChromeDriverManager().install()
driver = webdriver.Chrome(driver_path, chrome_options=chrome_options)
driver.implicitly_wait(60)
driver.get('https://www.instagram.com/')
username_input = WebDriverWait(browser, 60).until(EC.visibility_of_element_located((By.XPATH, "//input[@name='username']")))
password_input = browser.find_element_by_css_selector("input[name='password']")
username_input.send_keys("test")
password_input.send_keys("test")
login_button = browser.find_element_by_xpath("//button[@type='submit']")
login_button.click()
seleniumwire
我使用和早些时候打开 Instagram 登录 url跟踪我的请求给 301,但添加后user agent
我现在得到 200 的 Instagram 登录 url。
但现在它无法找到用户名输入字段。
PS - 这在本地 macOS 机器上工作正常,但不能在Heroku
解决方案
推荐阅读
- .net - IEnumerable.Min() 使用通用对象返回奇怪的结果
- mysql - 我可以选择每一行并限制具有不同值的行吗?
- python - 何修复 playsound excpetion “playbin.set_state 返回
我正在尝试使用该
playsound
模块在 Python 中制作一个简单的节拍器。但是当我运行它时,出现以下错误:Traceback (most recent call last): File "/run/media/mb/Vol
- azure-active-directory - Microsoft Botframework V4 虚拟助手 Azure AD 身份验证
- c - 如何让 C 程序发出 HTTP 请求并读取响应?
- c# - 如何更改一定数量的按钮(x)的不透明度,而不是一一写出来?(C#)
- android - 在 React-Native 中存储不可更改数据的正确方法
- html - Html 日期格式更改为月份日期年份
- xamarin - 如何在适用于 Android 的 Xamarin.Forms 应用程序中使用 D8、R8?
- maven - CircleCI Java 11 构建失败