BeautifulSoup - 提取属性值 [英] BeautifulSoup - extracting attribute values

查看:21
本文介绍了BeautifulSoup - 提取属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 Beautiful Soup 给我一个这样的锚标签:

If Beautiful Soup gives me an anchor tag like this:

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

我将如何检索 href 属性的值?

How would I retrieve the value of the href attribute?

推荐答案

如果你已经有了锚点,像这样获取 href 属性:

If you already have the anchor, grab the href attribute like this:

href = anchor["href"]

这篇关于BeautifulSoup - 提取属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆