Python Web Scraper with Only 4 Lines of Code

This tutorial will show how to create a web scraper with only 4 line of code. A web scraper copies all of the data from a web page and converts the html to readable text. To get started you will need to import two Python libraries BeautifulSoup and urllib

urllib will be used to to handle URLs and BeautifulSoup will be used to parse web site html.

  1. Line : Setting variable to web link
  2. Line : Opening Webpage of the link done by using urlopen()
  3. Line : Reading and decoding html using .read().decode()
  4. Line : Parsing text from html using BeautifulSoup() and html.parser which is a built in HTML parser
from bs4 import BeautifulSoup
from urllib.request import urlopen

# website being scraped
url = "https://codeit.blog/beginner-python-tutorial-1-the-basics/"

# opening URL
webpage = urlopen(url)

# Reading and decoding 
html = webpage .read().decode("utf-8")

# Parsing text from html 
bs = BeautifulSoup(html, "html.parser")

print(bs.get_text())
Output :
Python for Beginners #1 The Basics
Python is a user friendly, object oriented programming language. It was created in 1991 by  Guido van Rossum. Python was designed to be easily read and uses simple syntax. This makes Python great for beginners. 
Python can be used for:
Web Development Data Science Data Analysis Machine Learning 

Android Studio Loading Animation Between Activities

Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the … Read more Android Studio Loading Animation Between Activities

Android Studio Tutorial SeekBar

SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value … Read more Android Studio Tutorial SeekBar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s