Я собираю названия продуктов, Старая цена, Новая цена с веб-сайта, используя Python Beautifulsoup.
Когда я проверяю страницу, используя chrome, я могу видеть div, однако, когда я Пройдите через python, новый ценовой блок не найден.
Вот мой код
import requests
from bs4 import BeautifulSoup
for j in range(1,8):
page_link = 'https://sturdysports.com.au/?p='+str(j)
page_response = requests.get(page_link)
page_content = BeautifulSoup(page_response.content, 'html.parser')
#This is product wrapper, there are 12 on each page, so we want to find all info under this tag
products = page_content.find_all('li', class_='item product product-item')
for i in range(0,len(products)):
name = products[i].find('a', class_='product-item-link').text.strip()
#Tried traversing using 2-3 methods. None works.
prices = products[i].find('div',class_='price-box price-final_price')
rrp = products[i].find('span', attrs={"data-price-type":"oldPrice"})["data-price-amount"]
#op = products[i].find('span', attrs={"data-price-type":"finalPrice"})["data-price-amount"]
op = products[i].find('span',class_='special-price')
print(op)
data = '"' + name + '","' + rrp + '","' + op + '"\n'
print(" Item#: "+ str(i) + ' ' + data)