Skip to content

Commit 500d12b

Browse files
committed
Scraping
1 parent 5eacdf6 commit 500d12b

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
@@ -2448,7 +2448,7 @@ Scraping
24482448
#### Scrapes Python's URL, version number and logo from Wikipedia page:
24492449
```python
24502450
# $ pip3 install requests beautifulsoup4
2451-
import requests
2451+
import requests, sys
24522452
from bs4 import BeautifulSoup
24532453
URL = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
24542454
try:
@@ -2464,7 +2464,7 @@ try:
24642464
file.write(image)
24652465
print(link, ver)
24662466
except requests.exceptions.ConnectionError:
2467-
print("You've got problems with connection.")
2467+
print("You've got problems with connection.", file=sys.stderr)
24682468
```
24692469

24702470

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@
21142114
<li><strong><code class="python hljs"><span class="hljs-string">'&lt;str&gt;'</span></code> - Max age as a string: <code class="python hljs"><span class="hljs-string">'1 week, 3 days'</span></code>, <code class="python hljs"><span class="hljs-string">'2 months'</span></code>, …</strong></li>
21152115
</ul>
21162116
<div><h2 id="scraping"><a href="#scraping" name="scraping">#</a>Scraping</h2><div><h4 id="scrapespythonsurlversionnumberandlogofromwikipediapage">Scrapes Python's URL, version number and logo from Wikipedia page:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install requests beautifulsoup4</span>
2117-
<span class="hljs-keyword">import</span> requests
2117+
<span class="hljs-keyword">import</span> requests, sys
21182118
<span class="hljs-keyword">from</span> bs4 <span class="hljs-keyword">import</span> BeautifulSoup
21192119
URL = <span class="hljs-string">'https://en.wikipedia.org/wiki/Python_(programming_language)'</span>
21202120
<span class="hljs-keyword">try</span>:
@@ -2130,7 +2130,7 @@
21302130
file.write(image)
21312131
print(link, ver)
21322132
<span class="hljs-keyword">except</span> requests.exceptions.ConnectionError:
2133-
print(<span class="hljs-string">"You've got problems with connection."</span>)
2133+
print(<span class="hljs-string">"You've got problems with connection."</span>, file=sys.stderr)
21342134
</code></pre></div></div>
21352135

21362136

0 commit comments

Comments
 (0)