Python 下载百度贴吧的图片

来源:互联网 发布:java中的length方法 编辑:程序博客网 时间:2024/05/01 18:24
#coding=utf-8import urllibimport redef getHtml(url):    page = urllib.urlopen(url)    html = page.read()    return htmldef getImg(html):    reg = r'src="(.+?\.jpg)" pic_ext'    imgre = re.compile(reg)    imglist = re.findall(imgre,html)    x = 0    for imgurl in imglist:        urllib.urlretrieve(imgurl,'%s.jpg' % x)        x+=1html = getHtml("http://tieba.baidu.com/p/2460150866")print getImg(html)
0 0
原创粉丝点击