Skip to content

Commit 69ee037

Browse files
committed
Added Selenium
1 parent 633575c commit 69ee037

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,20 @@ Scraping
18081808
('https://www.python.org/', '3.7.2')
18091809
```
18101810

1811+
### Selenium
1812+
**Library for scraping dynamically generated web content.**
1813+
1814+
```python
1815+
# $ brew cask install chromedriver
1816+
# $ pip3 install selenium
1817+
>>> from selenium import webdriver
1818+
>>> driver = webdriver.Chrome()
1819+
>>> driver.get(url)
1820+
>>> xpath = '//*[@id="mw-content-text"]/div/table[1]/tbody/tr[7]/td/div'
1821+
>>> driver.find_element_by_xpath(xpath).text.split()[0]
1822+
'3.7.2'
1823+
```
1824+
18111825

18121826
Web
18131827
---

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,17 @@ <h2 id="scraping"><a href="#scraping" name="scraping">#</a>Scraping</h2>
14831483
<span class="hljs-meta">&gt;&gt;&gt; </span>link, ver
14841484
(<span class="hljs-string">'https://www.python.org/'</span>, <span class="hljs-string">'3.7.2'</span>)
14851485
</code></pre>
1486+
<h3 id="selenium">Selenium</h3>
1487+
<p><strong>Library for scraping dynamically generated web content.</strong></p>
1488+
<pre><code class="python language-python hljs"><span class="hljs-comment"># $ brew cask install chromedriver</span>
1489+
<span class="hljs-comment"># $ pip3 install selenium</span>
1490+
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> selenium <span class="hljs-keyword">import</span> webdriver
1491+
<span class="hljs-meta">&gt;&gt;&gt; </span>driver = webdriver.Chrome()
1492+
<span class="hljs-meta">&gt;&gt;&gt; </span>driver.get(url)
1493+
<span class="hljs-meta">&gt;&gt;&gt; </span>xpath = <span class="hljs-string">'//*[@id="mw-content-text"]/div/table[1]/tbody/tr[7]/td/div'</span>
1494+
<span class="hljs-meta">&gt;&gt;&gt; </span>driver.find_element_by_xpath(xpath).text.split()[<span class="hljs-number">0</span>]
1495+
<span class="hljs-string">'3.7.2'</span>
1496+
</code></pre>
14861497
<h2 id="web"><a href="#web" name="web">#</a>Web</h2>
14871498
<pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install bottle</span>
14881499
<span class="hljs-keyword">from</span> bottle <span class="hljs-keyword">import</span> run, route, post, template, request, response

0 commit comments

Comments
 (0)