简体   繁体   English

BeautifulSoup - 提取属性值

[英]BeautifulSoup - extracting attribute values

If Beautiful Soup gives me an anchor tag like this: 如果Beautiful Soup给我一个这样的锚标记:

<a class="blah blah" id="blah blah" href="link.html"></a>

How would I retrieve the value of the href attribute? 我如何检索href属性的值?

如果您已经拥有锚点,请抓住href属性,如下所示:

href = anchor["href"]
link.get('href')

其中'link'是'a'标签的名称

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

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