Skip to content

Commit 46f2254

Browse files
committed
Scraping
1 parent ba8467a commit 46f2254

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,8 +2292,8 @@ Scraping
22922292
import requests
22932293
from bs4 import BeautifulSoup
22942294
url = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
2295-
resp = requests.get(url)
2296-
doc = BeautifulSoup(resp.text, 'html.parser')
2295+
html = requests.get(url).text
2296+
doc = BeautifulSoup(html, 'html.parser')
22972297
table = doc.find('table', class_='infobox vevent')
22982298
rows = table.find_all('tr')
22992299
link = rows[11].find('a')['href']

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,8 +1973,8 @@
19731973
<span class="hljs-keyword">import</span> requests
19741974
<span class="hljs-keyword">from</span> bs4 <span class="hljs-keyword">import</span> BeautifulSoup
19751975
url = <span class="hljs-string">'https://en.wikipedia.org/wiki/Python_(programming_language)'</span>
1976-
resp = requests.get(url)
1977-
doc = BeautifulSoup(resp.text, <span class="hljs-string">'html.parser'</span>)
1976+
html = requests.get(url).text
1977+
doc = BeautifulSoup(html, <span class="hljs-string">'html.parser'</span>)
19781978
table = doc.find(<span class="hljs-string">'table'</span>, class_=<span class="hljs-string">'infobox vevent'</span>)
19791979
rows = table.find_all(<span class="hljs-string">'tr'</span>)
19801980
link = rows[<span class="hljs-number">11</span>].find(<span class="hljs-string">'a'</span>)[<span class="hljs-string">'href'</span>]

0 commit comments

Comments
 (0)