英文:
How to properly load website using selenium in python
问题
I'm trying to use selenium to open this link using the code below, but it seems to open just a very raw form of the website, with which I'm not managing to interact properly with the buttons.
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = webdriver.Chrome(service=Service(driver_path), options=options)
driver.get("https://aeromexico.com/es-mx")
What I wanted was for the page to load fully just as it does when I open it manually via Chrome, as the image below:
What am I doing wrong here?
英文:
I'm trying to use selenium to open this link using the code below, but it seems to open just a very raw form of the website, with which I'm not managing to interact properly with the buttons.
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = webdriver.Chrome(service=Service(driver_path), options=options)
driver.get("https://aeromexico.com/es-mx")
What I wanted was for the page to load fully just as it does when I open it manually via Chrome, as the image below:
What am I doing wrong here?
答案1
得分: 0
问题的根本原因: 您正在尝试使用Selenium访问的网站检测到了自动化机器人,因此不允许Selenium访问该网站。因此,您看到了网站的原始形式。
解决方法: 下载并导入undetected chrome driver
库到您的项目中并使用它。一旦导入该库,请尝试以下代码:
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.maximize_window()
driver.get("https://aeromexico.com/es-mx")
结果:
有关undetected chrome driver
的更多信息,请参考以下链接:
https://www.zenrows.com/blog/undetected-chromedriver#how-to
英文:
Root cause of the issue: The website you are trying to access using selenium is detecting the automation bot, and it is not allowing selenium to access the site. Hence you see the raw form of the website.
Solution: Download and import the undetected chrome driver
library into your project and use it. Once you import the library try the code as below:
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.maximize_window()
driver.get("https://aeromexico.com/es-mx")
Result:
Refer below link for more info about undetected chrome driver
:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论