TypeError: unsupported format string passed to dict.__format__
Всем привет. Пишу парсер, вот код:
import requests
def parse():
URL = input()
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/86.0.4240.185 Safari/537.36'
}
response = requests.get(URL, headers=HEADERS)
soup = BeautifulSoup(response.content, 'html.parser')
items = soup.findAll('div', class_='offer-wrapper')
comps = []
for item in items:
comps.append({
'title': item.find('a',
class_='marginright5 link linkWithHash detailsLinkPromoted linkWithHashPromoted').get_text(
strip=True),
'price': item.find('p', class_='price').get_text(strip=True),
'link': item.find('a',
class_='marginright5 link linkWithHash detailsLinkPromoted linkWithHashPromoted').get(
'href')
})
for comp in comps:
print(f'{comp["title"]} -> Price: {comp:["price"]} -> Link: {comp["link"]}')
parse()
Ввод:
https://www.olx.pl/sport-hobby/rowery/
Вывод:
File "C:/Users/probo/PycharmProjects/parser/main.py", line 31, in <module>
parse()
File "C:/Users/probo/PycharmProjects/parser/main.py", line 29, in parse
print(f'{comp["title"]} -> Price: {comp:["price"]} -> Link: {comp["link"]}')
TypeError: unsupported format string passed to dict.__format__
ПОЖАЛУЙСТА, ПОМОГИТЕ РАЗОБРАТЬСЯ!