今天用 python 抓取网站的时候,发现网页内有很多内页. 比如: 这个网页 里边有很多的超链接. 之前都是用java 做的. 转手用python 后怎么实现呢? python 抓取网页如何去除html 超链接href 代码如下:
soup = BeautifulSoup('<p>Hello <a href="http://google.com">Google</a></p>')
for a in soup.findAll('a'):
del a['href']
print (soup)
结果:
<p>Hello <a>Google</a></p>