假设有一个HTML链接:
<a href="urltxt" class="someclass" close="true">texttxt</a>
我该如何分离网址和文本?
更新
我正在使用Beautiful Soup,但无法弄清楚如何做到这一点。
我已经尝试了一些方法:
soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url))
links = soup.findAll('a')
for link in links:
print "link content:", link.content," and attr:",link.attrs
i get
*link content: None and attr: [(u'href', u'_redirectGeneric.asp?genericURL=/root /support.asp')]* ...
...
为什么我看不到内容?
编辑:根据建议详细说明了“卡住”的问题 :)