Browse Source

Scraping

pull/57/head
Jure Šorn 4 years ago
parent
commit
500d12bc06
2 changed files with 4 additions and 4 deletions
  1. 4
      README.md
  2. 4
      index.html

4
README.md

@ -2448,7 +2448,7 @@ Scraping
#### Scrapes Python's URL, version number and logo from Wikipedia page:
```python
# $ pip3 install requests beautifulsoup4
import requests
import requests, sys
from bs4 import BeautifulSoup
URL = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
try:
@ -2464,7 +2464,7 @@ try:
file.write(image)
print(link, ver)
except requests.exceptions.ConnectionError:
print("You've got problems with connection.")
print("You've got problems with connection.", file=sys.stderr)
```

4
index.html

@ -2114,7 +2114,7 @@ logger.&lt;level&gt;(<span class="hljs-string">'A logging message.'</span>)
<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>
</ul>
<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>
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> requests, sys
<span class="hljs-keyword">from</span> bs4 <span class="hljs-keyword">import</span> BeautifulSoup
URL = <span class="hljs-string">'https://en.wikipedia.org/wiki/Python_(programming_language)'</span>
<span class="hljs-keyword">try</span>:
@ -2130,7 +2130,7 @@ URL = <span class="hljs-string">'https://en.wikipedia.org/wiki/Python_(programmi
file.write(image)
print(link, ver)
<span class="hljs-keyword">except</span> requests.exceptions.ConnectionError:
print(<span class="hljs-string">"You've got problems with connection."</span>)
print(<span class="hljs-string">"You've got problems with connection."</span>, file=sys.stderr)
</code></pre></div></div>

Loading…
Cancel
Save