简体   繁体   中英

BeautifulSoup: can't find the text in the nest

无法提取销售额

I'm trying to get to the number of sales but I can't seem to reach the nest?

I've built this function so far and I can extract the spans, but can't go over the spans... :(

I've tried extracting it using the class (and regex to make it less specific) but to no avail. I've also tried using .find_all('span',c)

def getInfo(listing_link):
    
    response = requests.get(listing_link)
    html = response.text
    soup = BeautifulSoup(html, "html.parser")
    
    #print(len(list(soup.descendants)))
    
    c = re.compile("wt-text-caption ")
    

    for child in soup.find_all('div'):
        for baby in child.descendants: 
            bar = baby.find('span')
            print(bar)
            for i in bar:
                sales = i.find_all("span", c)
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
soup.find_all('span', attrs={"class":"wt-text-caption"})

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