Skip to content

Commit 7013607

Browse files
committed
Scraping
1 parent d6d08f4 commit 7013607

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,15 +1598,15 @@ Scraping
15981598
# $ pip3 install requests beautifulsoup4
15991599
>>> import requests
16001600
>>> from bs4 import BeautifulSoup
1601-
>>> url = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
1602-
>>> page = requests.get(url)
1603-
>>> document = BeautifulSoup(page.text, 'html.parser')
1604-
>>> table = document.find('table', class_='infobox vevent')
1605-
>>> rows = table.find_all('tr')
1606-
>>> link = rows[11].find('a')['href']
1607-
'https://www.python.org/'
1608-
>>> latest_v = rows[6].find('div').text.split()[0]
1609-
'3.7.2'
1601+
>>> url = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
1602+
>>> page = requests.get(url)
1603+
>>> doc = BeautifulSoup(page.text, 'html.parser')
1604+
>>> table = doc.find('table', class_='infobox vevent')
1605+
>>> rows = table.find_all('tr')
1606+
>>> link = rows[11].find('a')['href']
1607+
>>> ver = rows[6].find('div').text.split()[0]
1608+
>>> link, ver
1609+
('https://www.python.org/', '3.7.2')
16101610
```
16111611

16121612

0 commit comments

Comments
 (0)