繁体   English   中英

BeautifulSoup:在嵌套中找不到文本

[英]BeautifulSoup: can't find the text in the nest

无法提取销售额

我正在尝试获取销售数量,但我似乎无法到达巢穴?

到目前为止,我已经构建了这个 function,我可以提取跨度,但不能在跨度上提取 go...:(

我试过使用 class(和正则表达式来降低它的具体性)来提取它,但无济于事。 我也试过使用.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"})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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