使用Beautiful Soup从HTML提取Span的值

时间:2019-08-20 02:03:14

标签: python web-scraping beautifulsoup

我需要在类之后和一行HTML中的结束标记之前提取一个特定的字符串,该字符串已经使用漂亮的汤从findall函数中的变量中提取了

number_of_reviews = container.find_all("span",{"class":"lemon span__373c0__3997G text__373c0__2pB8f reviewCount__373c0__2r4xT text-color--mid__373c0__3G312 text-align--left__373c0__2pnx_"})
print(number_of_reviews)

这是我运行文件时的输出:

runfile('C:/Users/gbell/.spyder-py3/Club Webscrape/Web scrape scratch paper.py', wdir='C:/Users/gbell/.spyder-py3/Club Webscrape')
Tunnel
3 star rating
[<span class="lemon--span__373c0__3997G text__373c0__2pB8f reviewCount__373c0__2r4xT text-color--mid__373c0__3G312 text-align--left__373c0__2pnx_">101 reviews</span>]

我知道如何在特定属性(例如class =或name =

)之后打印字符串

但是html代码中的文本### reviews

373c0__2pnx_">101 reviews</span>]

似乎无法以相同的方式拉出。我该怎么做?

0 个答案:

没有答案