Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python scraping

#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

best scraping package in python

pip install scrapy
Comment

python web scraping

	#Run request
	url = "https://nanolooker.com/account/" + address
    response = requests.get(url)

    if response.ok:
        # Make some soup
    	soup = BeautifulSoup(response.text, "lxml")

        #Show the title
    	print("The title is: " + str(soup.title.string))
Comment

PREVIOUS NEXT
Code Example
Python :: python . 
Python :: python sqrt 
Python :: array sort python 
Python :: json to argparse 
Python :: Create an array of 10 zeros 
Python :: get key from dict python 
Python :: Python create a new png file 
Python :: python array join 
Python :: continue python 
Python :: python class arbitrary arguments 
Python :: how to copy the list in python 
Python :: dictionary in python 
Python :: Kivy FileChooser 
Python :: python panda count excel sheet 
Python :: urllib.error.HTTPError: HTTP Error 404: Not Found 
Python :: pandas value in series 
Python :: word counter python 
Python :: identity matrix python 
Python :: math module sin() function in python 
Python :: django create super user 
Python :: pandas knn imputer 
Python :: is fastapi better than flask 
Python :: stack in python using linked list 
Python :: extract value from tensor pytorch 
Python :: check if any letter in string python 
Python :: install python macos catalina 
Python :: Detect Word Then Send Message (discord.py) 
Python :: calculate the shortest path of a graph in python 
Python :: import python file from another directory 
Python :: random integer 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =