【发布时间】:2022-01-25 12:37:10
【问题描述】:
我正在尝试使用 selenium 和 python 进行抓取,网页在 javascript 中有一个分页器,当我单击按钮时,我可以看到内容重新加载但是当我尝试获取新的表信息时它是相同的旧表信息,selenium 没有注意到 de DOM 信息发生了变化,我知道过时的 DOM,我只是在寻找解决这个问题的最佳途径
for link in source.find_all('div', {'class': 'company-row d-flex'}):
print(link.a.text, link.small.text, link.find('div', {'class': 'col-2'}).text)
# Next button (I´ll make an iterator)
driver.find_element_by_xpath('//a[@href="hrefcurrentpage=2"]').click()
# Tried this and doesn't work
# time.sleep(5)
# Here the table change but get the same old info
for link in source.find_all('div', {'class': 'company-row d-flex'}):
print(link.a.text, link.small.text, link.find('div', {'class': 'col-2'}).text) ```
【问题讨论】:
标签: python selenium web-scraping