Практика НГУ. Написание парсера на Python

трансляция практического занятия для студентов НГУ. Мои: Instagram: Личный сайт (с блогом по разработке): Интернет-магазин: https://фурукава.рф Код с занятия: from os import write import requests from bs4 import BeautifulSoup import fake_useragent import csv user = ().random headers = { ’user-agent’: user } def get_html(url): r = (url, headers = headers) return r def get_content(html): catalog = [] soup = BeautifulSoup(html, ’’) items = (’div’, class_=’preview-product’) for i in items: price = (’div’, class_=’price’).get_text() price = (’ ’, ’’).replace(’₽’, ’’) name = (’span’).get(’title’) if name == None: continue else: name = name[9:] ({ ’name’: name, ’price’: price, }) return catalog def save_file(items, path):
Back to Top