PY

SIMPLE WEB SCRAPER IN PYTHON

(a quick example)

<div id="product">   <img src="static/box.png" id="pImg">   <div id="pName">Empty Box</div>   <div id="pPrice">$12.34</div>   <div id="pDesc">It's an empty box.</div>   <input type="button" value="Add To Cart"                id="pAdd"> </div>

DUMMY HTML PRODUCT PAGE

01

LOAD REQUIRED MODULES import requests from bs4 import BeautifulSoup

PYTHON WEB SCRAPER

02

GET HTML html = requests.get("http://localhost").text

HTML PARSER soup = BeautifulSoup(html, "html.parser") name = soup.find("div", {"id": "pName"}).text desc = soup.find("div", {"id": "pDesc"}).text price = soup.find("div", {"id": "pPrice"}).text image = soup.find("img", {"id": "pImg"})["src"]