Как достать внутренний контент div из внешнего div при парсинге Python

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

Помогите пожалуйста, при парсинге страницы, нужно достать div(product-price__value) из другого div(product-price).

import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
import json

driver = webdriver.Chrome()
driver.implicitly_wait(10)
# inp_page = int(input("Введите страницы"))
for i in range(1, 2):
    driver.get('https://www.chitai-gorod.ru/search?phrase=манга&page=' + str(i))
    pag.append(driver.page_source)
for el in pag:
    html = BeautifulSoup(el, 'lxml')
    mangas = html.find_all('article', class_='product-card product-card product')
    m_name = html.find_all('div', class_='product-card__text')
    # m_price = html.find_all('div', class_='product-price__value')
    price = html.find_all('div', class_='product-price')
    m_price_old = html.find('div', class_='product-price__old')
    for prices in price:
        pri = price('div', class_='product-price__value').text[0]
        # price1 = m_price[0].text.strip()
        print(pri)

Ответы

▲ 0Принят
 mangas = soup(class_='product')
    for x in mangas:
        name = x.find(class_='product-title__head').text.strip()
        price = x.find(class_='product-price__value').text.strip()
        print(name)
        print(price)
        price_old = x.find(class_='product-price__old')
        if price_old:
            print(price_old.text.strip())