python小白,刚接触python一个多月,发现自己已经爱上python这一门语言了,自己便做些相应的笔记,方便自己的复习,也希望自己走的弯路能够给大家一点借鉴的意义。
#-*- coding:utf-8 -*-
#qq564631192
"""
说明该函数是斯巴达第五讲,主要的作用是把相应的网站上的.jpg格式的图片爬取下来
"""
import re
import urllib
def getHtml(url):
html=urllib.urlopen(url)
content=html.read()
html.close()
return content
def get_images(info):
""".doc"""
regex=r'class="BDE_Image" src="(.+?\.jpg)"'
pat=re.compile(regex)
images_code=re.findall(pat,info)
# print len(images_code)
i=0
for image_url in images_code:
print image_url
urllib.urlretrieve(image_url,'%s.jpg' % i)
i+=1
info = getHtml("http://tieba.baidu.com/p/2772656630?fr_bdps_bottom_login=1")
print get_images(info)
161

被折叠的 条评论
为什么被折叠?



