У меня возникла проблема с отображением URL в моей программе
print(items[0].find(class_='product-card__link-overlay'))
linki = [item.find(class_='product-card__link-overlay').get_text() for item in items]
Я не знаю, как изменить их для отображения html ссылок вместо имен
, например, я хочу изменить его 0 Nike Air Max 270 React 679,99 zł Nike Air Max 270 React to 0 Nike Air Max 270 React 679,99 zł htttps: // www.nike.com/products/nikereact/id....
КОД:
import pandas as pd
import requests
from bs4 import BeautifulSoup
import re
odpowiedz = requests.get("https://www.nike.com/pl/w?q=react%20270&vst=react%20270")
soup = BeautifulSoup(odpowiedz.text, 'html.parser')
nazwa = soup.find(id='Nike Air Max 270 React')
#print(nazwa)
items = soup.find_all(class_='product-card css-1pclthi ncss-col-sm-6 ncss-col-lg-4 va-sm-t product-grid__card')
#print(items)
#for link in soup.findAll('a', attrs={'href': re.compile("^https://")}):
#print(link.get('href'))
#linki = soup.find('a', id='product-card css-1pclthi ncss-col-sm-6 ncss-col-lg-4 va-sm-t product-grid__card')
#print(linki)
print(items[0].find(class_='product-card__title').get_text())
print(items[0].find(class_='product-card__price').get_text())
print(items[0].find(class_='product-card__link-overlay'))
#print(items[0].find(class_='product-card__link-overlay'))
title = [item.find(class_='product-card__title').get_text() for item in items]
price = [item.find(class_='product-card__price').get_text() for item in items]
linki = [item.find(class_='product-card__link-overlay').get_text() for item in items]
wynik = pd.DataFrame(
{
'title': title,
'price': price,
'linki': linki,
})