diff --git a/README.md b/README.md index 1134a85..6a0270d 100644 --- a/README.md +++ b/README.md @@ -2300,7 +2300,7 @@ retention=|| Scraping -------- -#### Scrapes and prints Python's URL and version number from Wikipedia: +#### Scrapes Python's URL, version number and logo from Wikipedia page: ```python # $ pip3 install requests beautifulsoup4 import requests @@ -2312,15 +2312,11 @@ table = doc.find('table', class_='infobox vevent') rows = table.find_all('tr') link = rows[11].find('a')['href'] 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 +url_i = rows[0].find('img')['src'] +image = requests.get(f'https:{url_i}').content with open('test.png', 'wb') as file: file.write(image) +print(link, ver) ``` diff --git a/index.html b/index.html index 9c50999..8da88b4 100644 --- a/index.html +++ b/index.html @@ -1981,7 +1981,7 @@ logger.<level>('A logging message.')
  • '<timedelta>' - Max age of a file.
  • '<str>' - Max age as a string: '1 week, 3 days', '2 months', …
  • -

    #Scraping

    Scrapes and prints Python's URL and version number from Wikipedia:

    # $ pip3 install requests beautifulsoup4
    +

    #Scraping

    Scrapes Python's URL, version number and logo from Wikipedia page:

    # $ pip3 install requests beautifulsoup4
     import requests
     from bs4 import BeautifulSoup
     url   = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
    @@ -1991,16 +1991,14 @@ table = doc.find('table', class_='tr')
     link  = rows[11].find('a')['href']
     ver   = rows[6].find('div').text.split()[0]
    +url_i = rows[0].find('img')['src']
    +image = requests.get(f'https:{url_i}').content
    +with open('test.png', 'wb') as file:
    +    file.write(image)
     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