简体   繁体   中英

Beautiful Soup find nested div

I am trying to parse a webpage that looks like this with Python->Beautiful Soup

see image

I need data from

 <div class="p-offer__price-new">199,99 ₽</div> 

I tried this code:

soup = BeautifulSoup(data)
res = soup.findAll("div", {"class": "poffer__price-new"})
print(res)

But result is empty -- []

How can I get this data? Example of URL: https://edadeal.ru/moskva/offers/d71b75ff-bfee-4731-95ad-52a24ddea72e?from=%2F

import bs4
from selenium import webdriver 

driver = webdriver.Chrome('C:\chromedriver_win32\chromedriver.exe')
driver.get('https://edadeal.ru/moskva/offers/d71b75ff-bfee-4731-95ad-52a24ddea72e?from=%2F')

html = driver.page_source

soup = bs4.BeautifulSoup(html,'html.parser')
res = soup.findAll("div", {"class": "p-offer__price-new"})   
print (res[0].text)  

driver.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM