Как спрасить цену из выпадающей ссылки?

Рейтинг: 0Ответов: 1Опубликовано: 21.02.2023

Есть задание: спарсить цену из конкретных ссылок, одна из которых - https://pechisamara.ru/otopitelnye-pechi.html#images-4. Вроде бы, тег обозначен верно, класс тоже, однако выводит пустой результат. В чём проблема?

response = requests.get(url=url, headers=headers)
soup = BeautifulSoup(response.text, 'lxml')
price = soup.find('div', class_='fancybox-caption__body')
print(price.text)

Ответы

▲ 0
import requests
from bs4 import BeautifulSoup

url = 'https://pechisamara.ru/otopitelnye-pechi.html#images-4'
indx = int(url.rsplit('-', 1)[1])
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
lst = [x.text for x in soup.find_all('p', class_="price")]
print(lst[indx-1])