Posts

Showing posts from December, 2023

Web scraping in Python

  Here are some popular options and examples to get you started: 1. Beautiful Soup: Description: Powerful library for parsing HTML and XML documents. It helps extract specific data and organize it into a structured format. Example: Scraping product names and prices from an online store website. Python import requests from bs4 import BeautifulSoup   url = "https://www.example.com/products" response = requests.get(url) soup = BeautifulSoup(response.content, "html.parser" )   # Extract product names and prices products = [] for product in soup.find_all( "div" , class_= "product-item" ):     name = product.find( "h3" , class_= "product-name" ).text     price = product.find( "span" , class_= "product-price" ).text     products.append({ "name" : name, "price" : price})   print(products) 2. Requests: Description: Makes HTTP r...