擅长:python、mysql、java
<p>假设您在要解析的页面上,Selenium将源HTML存储在驱动程序的<code>page_source</code>属性中。然后将<code>page_source</code>加载到<code>BeautifulSoup</code>中,如下所示:</p>
<pre><code>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
</code></pre>