先看了廖雪峰Python教程,熟悉了一下语法,今天看到网上一位大神的实用教程Python爬虫学习系列教程挺有意思
最后上一段入门的例子:抓取网页图片并下载
#coding=utf-8
import urllib
import re
import pprint
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.+?\.jpg)" data-original'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
x = 0
for imgurl in imglist:
urllib.urlretrieve(imgurl,'%s.jpg' % x)
pprint.pprint(imgurl)
x+=1
html = getHtml("http://www.1tu.com/search/?k=technology")
print getImg(html)