作者:ZQ我是疯癫小karmenRJ | 来源:互联网 | 2023-09-25 20:41
importurllibimporturllib2importreurlhttp:sports.sina.com.cngchampionsleaguelocal
import urllib
import urllib2
import re
url="http://sports.sina.com.cn/g/championsleague/"
local='C:\\img\\'
cnt=0
uaheaders={'User-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0'}
req=urllib2.Request("http://sports.sina.com.cn/g/championsleague/")
res=urllib2.urlopen(req)
pattern=re.compile(r'src="(.*?.png)"')
text=res.read()
print(text)
word=pattern.findall(text)
print(word)
for line in word:
a=line.split('/')
urllib.urlretrieve(line,local+a[-1])
cnt+=1
print(cnt)