我试图用BeautifulSoup解析HTML。
我想要的内容是这样的:
<a class="yil-biz-ttl" id="yil_biz_ttl-2" href="http://some-web-url/" title="some title">Title</a>
我试图得到以下错误:
maxx = soup.findAll("href", {"class: "yil-biz-ttl"})
------------------------------------------------------------
File "<ipython console>", line 1
maxx = soup.findAll("href", {"class: "yil-biz-ttl"})
^
SyntaxError: invalid syntax
我想要的是字符串:http://some-web-url/
要查找所有此类链接:
在
"class
之后缺少右引号:应该是
另外,我不认为您可以搜索像
href
这样的属性,我认为您需要搜索标记:要从CSS类
"yil-biz-ttl"
中查找所有具有href
属性且其中包含任何内容的<a/>
元素:目前所有其他答案都不符合上述要求。
相关问题 更多 >
编程相关推荐