У меня проблема с отображением данных с двух разных сайтов в одном и том же файле html (в одной таблице).
Я много пробовал, ищу какие-то решения, но мне ничего не помогает. Вы также можете связать меня с любым учебником по python / bs / web-scraping к моим будущим "проблемам": D
Заранее спасибо.
КОД:
import pandas as pd
import requests
from bs4 import BeautifulSoup
odpowiedz = requests.get(
"https://www.nike.com/pl/w?q=react%20270&vst=react%20270")
soup = BeautifulSoup(odpowiedz.text, 'html.parser')
items = soup.find_all(
class_='product-card css-1pclthi ncss-col-sm-6 ncss-col-lg-4 va-sm-t product-grid__card')
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').attrs['href']
for item in items]
odpowiedz = requests.get(
"https://www.nike.com/pl/w/air-max-97-buty-77f38zy7ok")
soup = BeautifulSoup(odpowiedz.text, 'html.parser')
items = soup.find_all(
class_='product-card css-1pclthi ncss-col-sm-6 ncss-col-lg-4 va-sm-t product-grid__card')
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').attrs['href']
for item in items]
wynik = pd.DataFrame(
{
'Model': title,
'Cena': price,
'Link': linki,
})
print(wynik)
wynik.to_html('official.html')
Результат этой программы является id, название продукта, цена и ссылка (на обувь в этом примере) с 1-го сайта (Nike реагировать), и я хочу добавить данные со второго сайта (Nike Air Max 97) и добавить их также в таблицу с моим первым результат (Nike реагирует)