如何在python中使用Selenium和Beautifulsoup解析网站?

咖啡后抽搐:

编程新手,并弄清楚了如何使用Selenium导航到需要去的地方。我想立即解析数据,但不确定从哪里开始。有人可以握我的手几秒钟,并朝正确的方向指点我吗?

任何帮助表示赞赏-

火箭驴:

假设您在要解析的页面上,Selenium将源HTML存储在驱动程序的page_source属性中。这样,你会加载page_sourceBeautifulSoup如下:

In [8]: from bs4 import BeautifulSoup

In [9]: from selenium import webdriver

In [10]: driver = webdriver.Firefox()

In [11]: driver.get('http://news.ycombinator.com')

In [12]: html = driver.page_source

In [13]: soup = BeautifulSoup(html)

In [14]: for tag in soup.find_all('title'):
   ....:     print tag.text
   ....:     
   ....:     
Hacker News

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Python中使用Selenium?

如何在python中使用Selenium和Beautifulsoup解析网站?

如何在Python中使用BeautifulSoup提取标签内的文本?

如何在Selenium和Python中使用类型查找元素

如何在Python中使用BeautifulSoup从标记中提取innerHTML

如何在Python中使用多个键解析和排序JSON

如何在Python中使用BeautifulSoup创建链接?

如何使用Python和BeautifulSoup解析类

如何在python中使用beautifulsoup获取完整的href链接

如何在python,selenium和chromedriver中使用Brave Web浏览器?

如何在python中使用Selenium和javascript跟踪鼠标事件和位置?

如何在Python中使用Beautifulsoup仅打印文本?

如何在Python中使用beautifulsoup提取href内容

如何在python中使用BeautifulSoup抓取隐藏的表内容?

如何在Python中使用Beautifulsoup获取嵌套标签的文本?

使用Selenium和BeautifulSoup搜寻网站

如何在Selenium Python中使用JavaScript

使用BeautifulSoup和Selenium解析HTML内容

在python中使用beautifulsoup解析表

如何在 Python 中使用 selenium 刮取 > 和 < 之间的值?

使用来自 AJAX 网站的 selenium 和 beautifulsoup 在 python 中抓取图像

如何在 selenium 和 python 中使用下拉菜单和输入文本框?

使用 Selenium 和 Beautifulsoup 解析 JavaScript 输出

如何在 Python 中使用 selenium 登录网站?

如何在 Python 中使用 BeautifulSoup 从文本中获取标签

如何在 Python 中使用 BeautifulSoup 查找特定的 HTML 元素

如何在 Python 中使用 BeautifulSoup 理解“遞歸”

如何在 Python 中使用 Selenium 從 th 和 td 標籤中提取數據?

如何在 Python 3 中使用 Selenium 从网站的某个部分获取文本