【发布时间】:2021-01-18 09:24:57
【问题描述】:
我正在做一个项目,我必须去一个站点并在那里放一个大豆。我正在尝试使用 Python selenium 模块执行此操作,但是当我使用机器人进入站点时,我会收到一个弹出窗口(关于 cookie 的接受表)。如果不按接受,我将无法实现我想要做的事情。
我检查了站点的网络部分,发现该站点包含 cookie,当我进入该站点时,代码可以正常工作,并且成功按下接受 cookie 按钮,但这对我不起作用,因为它不能甚至在主站点上找到接受按钮,我知道不是因为它是用javascript编写的,但我不知道该怎么做。
不管怎样,让我们进入代码部分。
on the site I'm trying to login
the site that sent the cookie form the site uses
此代码适用于this:
from selenium import webdriver
import time
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
option = webdriver.ChromeOptions()
option.add_argument('--disable-notifications')
option.add_argument("--mute-audio")
driver = webdriver.Chrome("chromedriver.exe", options=option)
driver.get('https://consent-pref.trustarc.com/?type=jefftest_ibm&site=ibm.com&action=notice&country=tr&locale=tr&behavior=expressed>m=1&layout=default_eu&irm=undefined&from=https://consent.trustarc.com/#')
time.sleep(10)
driver.find_elements_by_class_name("call")[0].click()
但它不适用于另一个,我怎样才能让它也适用于另一个?
【问题讨论】:
标签: javascript python selenium popup