using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; using System.Collections; using System.IO; using System.Text.RegularExpressions; using RE = System.Text.RegularExpressions.Regex; using Sy
本文实例讲述了python获取指定网页上所有超链接的方法。分享给大家供大家参考。具体如下:
这段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
link