网页抓取数据(元素在点(625278.55)运行代码时出现错误:再次卡住)
优采云 发布时间: 2022-02-09 00:24网页抓取数据(元素在点(625278.55)运行代码时出现错误:再次卡住)
嗨,我正在尝试使用 python3.x 和 beauthoulsoup 从年龄验证弹出站点中抓取数据。如果不单击“是”到“您是否已超过 21 岁”,我将无法访问基础文本和图像。谢谢你的支持。存在
编辑:谢谢,在评论的帮助下,我发现我可以使用 cookie,但不知道如何使用 requests 包管理/存储/调用 cookie。存在
因此,在另一个用户的帮助下,我使用了 selenium 包,以便它也适用于图形叠加(我认为?)。很难让它与壁虎驱动程序一起工作,但会继续努力!再次感谢大家的建议。存在
编辑 3:好的,我已经取得了进展,我可以使用 gecko 驱动程序打开浏览器窗口!~不幸的是,它不喜欢那个链接规范,所以我再次发布。年龄验证点击“是”的链接隐藏在这个页面上,称为mlink。. . 存在
编辑 4:取得了一些进展,更新的代码如下。我设法在 XML 代码中找到了该元素,现在我只需要设法单击链接。存在
#
import time
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from bs4 import BeautifulSoup
driver = webdriver.Firefox(executable_path=r'/Users/jeff/Documents/geckodriver') # Optional argument, if not specified will search path.
driver.get('https://www.shopharborside.com/oakland/#/shop/412');
url = 'https://www.shopharborside.com/oakland/#/shop/412'
driver.get(url)
#
driver.find_element_by_class_name('hhc_modal-body').click(Yes)
#wait.1.second
time.sleep(1)
pagesource = driver.page_source
soup = BeautifulSoup(pagesource)
#you.can.now.enjoy.soup
print(soup.prettify())
编辑新:再次卡住,这是当前代码。我似乎隔离了元素“mBtnYes”,但是当我运行代码时出现错误: ElementClickInterceptedException: Message: Element at point (625278.55) is not clickable because another element make it blurable
^{pr2}$