Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

python soup

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

# $ pip3 install requests beautifulsoup4
import requests, bs4, os, sys

URL = 'https://en.wikipedia.org/wiki/Python_(programming_language)'
try:
    html       = requests.get(URL).text
    document   = bs4.BeautifulSoup(html, 'html.parser')
    table      = document.find('table', class_='infobox vevent')
    python_url = table.find('th', text='Website').next_sibling.a['href']
    version    = table.find('th', text='Stable release').next_sibling.strings.__next__()
    logo_url   = table.find('img')['src']
    logo       = requests.get(f'https:{logo_url}').content
    filename   = os.path.basename(logo_url)
    with open(filename, 'wb') as file:
        file.write(logo)
    print(f'{python_url}, {version}, file://{os.path.abspath(filename)}')
except requests.exceptions.ConnectionError:
    print("You've got problems with connection.", file=sys.stderr)
Comment

PREVIOUS NEXT
Code Example
Shell :: bash command for unzipping tar.gz files 
Shell :: uninstall qt creator ubuntu 
Shell :: stop tomcat from terminal mac 
Shell :: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 
Shell :: git username 
Shell :: check debian version 
Shell :: Failed to restart mongodb.service: Unit mongodb.service is masked. 
Shell :: ubuntu uninstall thingsboard 
Shell :: how to check battery health of laptop in cmd 
Shell :: PHP Fatal error: Class UpdateHelperComposerPlugin contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (ComposerPluginPluginInterface::deactivate 
Shell :: Amazon Linux 2 AMI install docker 
Shell :: install amplify cli mac 
Shell :: yum install node 
Shell :: reset cache pods 
Shell :: laravel rollback last migration 
Shell :: count number of files linux command 
Shell :: upgrade git on centos 7 
Shell :: adb port reverse 
Shell :: how to convert .qrc file in python 
Shell :: dotnet build release 
Shell :: psycopg2-binary install 
Shell :: How do I check my WSL version? 
Shell :: how to kill a port 
Shell :: install hardhat 
Shell :: git pull changes from master 
Shell :: command to install fish shell 
Shell :: upgrade version of node in windows 
Shell :: valet install command not found 
Shell :: conda install selenium 
Shell :: pm2 rename app 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =