diff --git a/README.md b/README.md index f60ecff..0daaf9b 100644 --- a/README.md +++ b/README.md @@ -2292,8 +2292,8 @@ Scraping import requests from bs4 import BeautifulSoup url = 'https://en.wikipedia.org/wiki/Python_(programming_language)' -page = requests.get(url) -doc = BeautifulSoup(page.text, 'html.parser') +resp = requests.get(url) +doc = BeautifulSoup(resp.text, 'html.parser') table = doc.find('table', class_='infobox vevent') rows = table.find_all('tr') link = rows[11].find('a')['href'] @@ -2301,6 +2301,14 @@ ver = rows[6].find('div').text.split()[0] print(link, ver) ``` +#### Downloads Python's logo: +```python +url_img = rows[0].find('img')['src'] +image = requests.get(f'https:{url_img}').content +with open('test.png', 'wb') as file: + file.write(image) +``` + Web --- diff --git a/index.html b/index.html index dce5113..caea88c 100644 --- a/index.html +++ b/index.html @@ -1973,8 +1973,8 @@ logger.<level>('A logging message.') import requests from bs4 import BeautifulSoup url = 'https://en.wikipedia.org/wiki/Python_(programming_language)' -page = requests.get(url) -doc = BeautifulSoup(page.text, 'html.parser') +resp = requests.get(url) +doc = BeautifulSoup(resp.text, 'html.parser') table = doc.find('table', class_='infobox vevent') rows = table.find_all('tr') link = rows[11].find('a')['href'] @@ -1983,6 +1983,12 @@ print(link, ver) +
url_img = rows[0].find('img')['src']
+image   = requests.get(f'https:{url_img}').content
+with open('test.png', 'wb') as file:
+    file.write(image)
+
+

#Web

# $ pip3 install bottle
 from bottle import run, route, post, template, request, response
 import json