python script that uses beautifulsoup to write the name, price and url to a .csv on…
- User
python script that uses beautifulsoup to write the name, price and url to a .csv on https://www.customsneakers.ch/collections/alle-sneaker?page=1 from ?page=1 to ?page=5
- Assistant
Below is a Python script that uses Beautiful Soup and 'requests' to scrape the sneakers' details like name, price, and URL and save them to a CSV file.
import requests from bs4 import BeautifulSoup import csv def get_page_soup(url): r = requests.get(url) soup = BeautifulSoup(r.content, "html.parser") return soup def get_sneaker_info(url): sneakers_data = [] soup = get_page_soup(url) sneakers = soup.find_all("div", class_="grid__item") for sneaker in sneakers: # Get sneaker name sneaker_name = sneaker.find("div", class_="product__title").text.strip() # Get sneaker price sneaker_price = sneaker.find("span", class_="money").text.strip() # Get sneaker URL sneaker_url = sneaker.find("a", class_="full_width_link")["href"] sneaker_url = f'https://www.customsneakers.ch{ sneaker_url }' sneakers_data.append([sneaker_name, sneaker_price, sneaker_url]) return sneakers_data def write_to_csv(sneakers_data, filename="sneakers_data.csv"): with open(filename, "a", newline="", encoding="utf-8") as f: writer = csv.writer(f) for sneaker_info in sneakers_data: writer.writerow(sneaker_info) def main(): base_url = "https://www.customsneakers.ch/collections/alle-sneaker?page=" header = ["Sneaker Name", "Price", "URL"] # Create a new CSV file and write the header with open("sneakers_data.csv", "w", newline="", encoding="utf-8") as f: writer = csv.writer(f) writer.writerow(header) for i in range(1, 6): # Loop through pages 1 to 5 sneakers_data = get_sneaker_info(base_url + str(i)) write_to_csv(sneakers_data) if __name__ == "__main__": main() - User
nice, now i have for exampleURL's like https://www.customsneakers.ch/collections/alle-sneaker/products/zurich-airforce-1 so i need to iterate through every URL that is in the .csv and save the Titel, Preis, Beschreibung, URL in a .csv adn the and the pictures that is in a standalone folder names after the Titel
- Assistant
- User
which web scraped data could i sell? make 10 suggestions
- Assistant
Selling web scraped data potentially raises legal and ethical concerns, so it's essential to ensure that you are abiding by the terms of service of the websites you scrape and adhere to applicable data protection regulations, such as GDPR. With that said, here are ten suggestions for industries or data types that could be valuable:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.