在 python 网页抓取中使用 Selenium 对 BeautifulSoup 进行分页

湿婆·戈文达萨米

我是 Webscraping 的新手,因此也是 bs4 和 selenium 的新手。我能够从奥运会奖牌获得者页面的表格中检索数据但我不知道如何从其余页面获取数据,因为它没有根据页面更新它的 url(基于我浏览的初始教程)。

我想知道在这种情况下如何循环浏览页面。

编辑:感谢所有的答案。每个答案都为我增加了一个概念,即以不同的方式从网站获取数据。谢谢。

预言家

要转到下一页,您必须单击页面右下角的next分页按钮。
为此,您必须向下滚动页面并单击该页面。
对于滚动,您将使用action_chains类。
因此,您将在每个页面上收集数据,然后执行以下操作:

next_page_btn = driver.find_element_by_xpath('//li[@class="paginate_button page-item next"]//a')
actions.move_to_element(next_page_btn).perform()
time.sleep(0.5)
next_page_btn.click()

在此之前,您必须导入

from selenium.webdriver.common.action_chains import ActionChains

actions

actions = ActionChains(driver)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Python进行网页抓取

使用BeautifulSoup进行网页抓取时出错

在Python中浏览Selenium并使用BeautifulSoup进行抓取

Python字符串转换为int / float [使用BeautifulSoup进行熊猫/网页抓取]

在Python标签中使用BeautifulSoup进行网络抓取

使用Python进行网页抓取

使用python,BeautifulSoup和pandas'read_html'进行网页抓取的问题

使用beautifulsoup进行Python网页抓取-无法从Clinicaltrials.gov提取首席调查员

使用BeautifulSoup Python抓取网页

使用 BeautifulSoup FindAll 进行网页抓取

如何使用 BeautifulSoup 进行网页抓取

使用 BeautifulSoup 进行网页抓取 -- Python

使用 Python BeautifulSoup 进行网页抓取

使用 BeautifulSoup 进行分页

使用 BeautifulSoup 通过分页抓取网页

使用 Python Selenium 性能进行网页抓取

Python / BeautifulSoup / Selenium 网页抓取 - 无法查看内容

使用 Selenium&gChrome 进行 Python 网页抓取

使用 Beautifulsoup 的 Python 网页抓取:lowes 商店

使用 beautifulsoup 进行网页抓取的问题

使用 BeautifulSoup 进行网页抓取 / Zomato 网页抓取

使用 BeautifulSoup 和 json 进行网页抓取

使用 Selenium 和 BeautifulSoup 进行网页抓取返回空列表

使用python进行网页抓取分页时迭代多个页面

使用 BeautifulSoup 遍历 URL 以进行网页抓取

网页抓取 Python BeautifulSoup

使用 Selenium 和 BeautifulSoup 进行 Zillow 网页抓取

在 Python 中使用 Selenium 进行网页抓取

使用 Selenium 进行 Python 抓取