【发布时间】:2021-05-19 02:55:16
【问题描述】:
我想从 youtube 视频中获取一些标签,例如标题、观看次数等。我为此使用 BeautifulSoup,但我想让它更快。这是我的代码:
#for the title
from BeautifulSoup import BeautifulSoup
html = re.findall('content=.*>\n\n',urllib2.urlopen(link).read())
soup = BeautifulSoup(html)
print soup.prettify()
#for the number of views
soup0 = BeautifulSoup(urllib2.urlopen(link).read())
for items in soup0.findAll('strong'):
if re.match("^[0-9]*$", str(items).strip("<strong>").rstrip("</strong>")):
viewcount=str(strongs).strip("<strong>").rstrip("</strong>")
【问题讨论】:
-
好吧,它真的很慢吗?
标签: python beautifulsoup