Ошибки в консоли нет, однако в консоли нет и конечного кода.
Все что выводиться в консоли: Process finished with exit code 0
Сам код:
import requests
from bs4 import BeautifulSoup
def parse():
URL = 'https://www.olx.ua/elektronika/kompyutery-i-komplektuyuschie/'
HEADERS = {
'User_Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 OPR/72.0.3815.465'
}
response = requests.get(URL, HEADERS)
soup = BeautifulSoup(response.content, 'html.parser')
items = soup.find_all('div', class_='offer-wrapper')
comps = []
for item in items:
comps.append({
'title': item.find('a', class_='marginright5 link linkWithHash detailsLink linkWithHashPromoted').get_text,
'price': item.find('p', class_='price').get_text(strip=True)
})
for comp in comps:
print(f"{comp['title']}")
parse()
AttributeError: 'NoneType' object has no attribute 'get_text'