您好,欢迎来到欧米美食网。
搜索
您的当前位置:首页python使用BeautifulSoup分页网页中超链接的方法

python使用BeautifulSoup分页网页中超链接的方法

来源:欧米美食网


本文实例讲述了python使用BeautifulSoup分页网页中超链接的方法。分享给大家供大家参考。具体如下:

python通过BeautifulSoup分页网页中的超级链接,这段python代码输出www.bitsCN.com主页上所有包含了jb51的url链接

from BeautifulSoup import BeautifulSoup
import urllib2
import re
url = urllib2.urlopen("http://www.bitsCN.com")
content = url.read()
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True):
 if re.findall('sharejs', a['href']):
 print "Found the URL:", a['href']

希望本文所述对大家的Python程序设计有所帮助。

Copyright © 2019- omca.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务