这段python代码通过urllib2抓取网页,然后通过简单的正则表达式分析网页上的全部url地址
import urllib2 import re #connect to a URL website = urllib2.urlopen(url) #read html code html = website.read() #use re.findall to get all the links links = re.findall('"((http|ftp)s?://.*?)"', html) print links
希望本文所述对大家的python程序设计有所帮助。
查看更多关于python获取指定网页上所有超链接的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did90872