import requests from bs4 import BeautifulSoup import csv HOST = 'https://www.olx.ua/' URL = 'https://www.olx.ua/d/zhivotnye/sobaki/' HEADERS = { 'accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' , 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36' } def get_html ( url , params = '' ) : r = requests . get ( url , headers = HEADERS , params = params ) return r def get_content ( html ) : soup = BeautifulSoup ( html , 'html.parser' ) items = soup . find_all ( 'div' , class_ = 'css-19ucd76' ) # Парс целого объявления cards = [ ] for item in items : cards . append ( { 'title' : item . find ( 'div' , class__ = 'css-u2ayx9' ) . get_text ( strip = True ) # Парс названия объявления } ) return cards