【发布时间】:2018-05-30 20:18:30
【问题描述】:
我遇到了一些我不太理解的奇怪行为。我希望有人能解释发生了什么。
考虑这个元数据:
<meta property="og:title" content="This is the Tesla Semi truck">
<meta name="twitter:title" content="This is the Tesla Semi truck">
此行成功找到所有“og”属性并返回一个列表。
opengraphs = doc.html.head.findAll(property=re.compile(r'^og'))
但是,这条线无法为 twitter 卡做同样的事情。
twitterCards = doc.html.head.findAll(name=re.compile(r'^twitter'))
为什么第一行成功找到了所有的“og”(opengraph 卡片),却没有找到twitter 卡片?
【问题讨论】:
标签: python html twitter web-scraping beautifulsoup