Python/Selenium - Cant click#39; Accept cookies#39; button on www.instagram.com(Python/Selenium - 无法单击 www.instagram.com 上的“接受 cookie按钮)
问题描述
我正在尝试使用 python selenium 登录 instagram.但我必须接受 cookie 才能继续.
Im trying to login on instagram using python selenium. But i have to Accept the cookies in order to continue.
这是我的代码
class InstaBot:
def __init__(self, username, pw):
self.driver = webdriver.Chrome()
self.driver.get('https://www.instagram.com/')
sleep(2)
#this is the code that im trying to use, so to click the accept button
self.driver.find_element_by_xpath("/html/body/div[2]/div/div/div/div[2]/button[1]").click()
self.driver.find_element_by_xpath("//input[@name="username"]")
.send_keys(username)
self.driver.find_element_by_xpath("//input[@name="password"]")
.send_keys(pw)
self.driver.find_element_by_xpath("//a[contains(text(), 'Log in')]")
.click()
sleep(4)
问题是当它点击接受按钮时它什么也不做.有什么想法吗?
The problem is that when it gets to click the accept button it does nothing. Any ideas?
推荐答案
试试这个:
self.driver.find_element_by_xpath("//button[text()='Accept']").click()
我在这里发布了我的解决方案:在 www.instagram.com 上使用 Python/Selenium 接受 cookie 错误
I posted my solution here: Accepting cookies error with Python/Selenium on www.instagram.com
这篇关于Python/Selenium - 无法单击 www.instagram.com 上的“接受 cookie"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Python/Selenium - 无法单击 www.instagram.com 上的“接受 cookie"按钮


基础教程推荐
- 求两个直方图的卷积 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01