Cześć wszystkim,
Mam taki problem chciałem sobie napisać skrypt w python do pobierania ogłoszeń z olx i stanąłem w miejscu... bo dostaję cały czas błąd:
price = advertisement.find('h3', {'class' : 'css-8kqr5l-Text eu5v0x0'}).text.strip()
TypeError: slice indices must be integers or None or have an index method
Czy ktoś może pomóc staremu dziadkowi co robi nie tak ;) Oto mój kod:
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
import sys
# Connect to the database
link = "https://www.olx.pl/d/oferta/echosonda-raymarine-dragonfly-5pro-najtaniej-w-polsce-1-CID767-IDHur6N.html"
print(link)
page = requests.get(link).content
announcements = BeautifulSoup(page, "html.parser")
for advertisement in announcements:
price = advertisement.find('h3', {'class' : 'css-8kqr5l-Text eu5v0x0'}).text.strip()
title = advertisement.find('h1', {'data-cy' : 'ad_title'}).text.strip()
description = advertisement.find('div', {'data-cy' : 'ad_description'}).text.strip()
views = advertisement.find('span', {'class' : 'css-1qvxqpo'}).text.strip()
Z góry dziękuję za pomoc