Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2021 16:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
uClient = uReq(my_url)
page_html =
page_soup = soup(page_html, "html.parser")
containers = page_soup.findAll("div", { "class": "_3O0U0u"})
container = containers[0]
price = container.findAll("div", {"class": "col col-5-12 _2o7WAb"})
ratings = container.findAll("div", {"class": "niH0FQ"})
filename = "products.csv"
headers = "Product_Name, Pricing, Ratings \n"
for container in containers:
product_name = container.div.img["alt"]
price_container = container.findAll("div", {"class": "col col-5-12 _2o7WAb"})
price = price_container[0].text.strip()
rating_container = container.findAll("div", {"class": "niH0FQ"})
rating = rating_container[0].text
print("Product_Name:"+ product_name)
print("Price: " + price)
print("Ratings:" + rating)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment