- 论坛徽章:
- 1
|
<a href="aaaas"><img src="saaa"/></a>
<a class="url" href="saasa">那个分享第二份职业,两个月...</a>
<a href="aaaaa"><img src="aaaaa"></a>
<a class="url" href="aaaaa">兼职一:这是一个在手机上赚...</a>
<a href="saa">缁欐垜鍏虫敞鐨勪汉鍐欎俊</a>
<a href="saaaat">鍘绘垜鍏虫敞鐨勪汉鍒楄〃</a>
我想匹配出class="url"标签- from bs4 import BeautifulSoup
- import string, re
- f = open('dy.html', 'r')
- html = f.readlines()
- soup = BeautifulSoup(string.join(html, ''))
- for link in soup.find_all('a'):
- print link.find(class_='url')
- print link.find(attrs={'class','url'})
复制代码 都显示None |
|