您的位置:首页 > 编程语言 > Python开发

【python】获取指定网页上的所有超级链接

2016-09-08 15:59 471 查看
# -*- coding: utf-8 -*-
import urllib2
import re

#connect to a URL
website = urllib2.urlopen("http://www.baidu.com")
#read html code
html = website.read()
#use re.findall to get all the links
links = re.findall('"((http|ftp)s?://.*?)"', html)  ###".*?"任意匹配
print links


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: