Web Scraping with Python and Beautiful Soup
Prerequisite Modules
In order to start scraping two modules are required bs4 and requests
pip3 install requests
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0)
pip3 install bs4
Collecting bs4 Downloading bs4-0.0.1.tar.gz (1.1 kB) Requirement already satisfied: beautifulsoup4 in /usr/lib/python3/dist-packages (from bs4) (4.8.2) Building wheels for collected packages: bs4 Building wheel for bs4 (setup.py) ... done Created wheel for bs4: filename=bs4-0.0.1-py3-none-any.whl size=1272 sha256=c643bb66a5f4ced4b2d015d665121f4ee6af6e5802eca585cede66fdafe208a4 Stored in directory: /home/u/.cache/pip/wheels/75/78/21/68b124549c9bdc94f822c02fb9aa3578a669843f9767776bca Successfully built bs4 Installing collected packages: bs4 Successfully installed bs4-0.0.1
Import Modules
from bs4 import BeautifulSoup
import requests
Examples
- IMDB Top Rated Movies