社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python接受cookies

JD. • 4 年前 • 1502 次点击  

我需要接受某个特定网站上的cookies,但我会不断收到 NoSuchElementException .这是进入网站的代码:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time


chrome_options = Options()
driver = webdriver.Chrome(executable_path='./chromedriver', options=chrome_options)

page_url = 'https://www.boerse.de/historische-kurse/Erdgaspreis/XD0002745517'
driver.get(page_url)

time.sleep(10)

我尝试通过以下方式接受cookie按钮:

driver.find_element_by_class_name('message-component message-button no-children focusable button global-font sp_choice_type_11 last-focusable-el').click()
driver.find_element_by_xpath('//*[@id="notice"]').click()
driver.find_element_by_xpath('/html/body/div/div[2]/div[4]/div/button').click()

说到硒,我是一个初学者,只是想用它做一个简短的变通。谢谢你的帮助。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/130933
文章 [ 1 ]  |  最新文章 4 年前