python爬虫技术实现图片提取
2017-04-30 17:38
741 查看
# -*- coding: UTF-8 -*- import urllib2,urllib,os ''' Created on 2017年4月16日 @author: 恋蝶 ''' mmurl = "https://mm.taobao.com/json/request_top_list.htm?type=0&page=" temp = "https://mm.taobao.com/self/aiShow.htm?spm=719.7763510.1998643336.1.pI7wQq&userId=" T = '''src="''' wjming = "E:\\Pythonpaqu\\Python\\picimg\\" i = 0 ph = -1 while i < 16: url = mmurl + str(i) up = urllib2.urlopen(url) cont = up.read() ahref = "user_id=" target = '''target="_blank"''' h=1 pa = cont.find(ahref) pt = cont.find(target, pa) while cont.find(ahref)>=0: userid = cont[pa + len(ahref): pt - 2] grzxurl = temp + userid mmup = urllib2.urlopen(grzxurl) imgcont = mmup.read() mtname = cont[pa + len(ahref): pt + 36] mta = '''target="_blank">''' mtb = '''</a>''' mtapa = mtname.find(mta) mtapb = mtname.find(mtb,mtapa) wjname = mtname[mtapa + len(mta) : mtapb] wjname = str(i) + wjname + str(h) h +=1 zzwjm = wjming + wjname isExists=os.path.exists(zzwjm) if not isExists: os.makedirs(zzwjm) print (zzwjm) imgsty = '''img style="float:''' tstar = "tstar.jpg" imgpa = imgcont.find(imgsty) imgpt = imgcont.find(tstar,imgpa) l=1 while imgcont.find(imgsty)>=0: whileimg = imgcont[imgpa + len(imgsty): imgpt+9] imgcont = imgcont[imgpt:] imgpa = imgcont.find(imgsty) imgpt = imgcont.find(tstar,imgpa) temurl = whileimg.find(T) imgurl = "http:" + whileimg[temurl + len(T):] urllib.urlretrieve(imgurl, zzwjm +"\\tu"+ str(l) + ".jpg") l +=1 cont = cont[pt:] pa = cont.find(ahref) pt = cont.find(target, pa) i += 1
相关文章推荐
- Python爬虫实现抓取网页图片
- python实现爬虫下载美女图片
- python3.5——爬虫实现批量下载图片(正则表达式法和BeautifulSoup第三方库法)
- Python爬虫实现爬取京东手机页面的图片(实例代码)
- python 实现一个贴吧图片爬虫的示例
- python 实现网站图片抓取小爬虫
- 网络爬虫之网站图片爬取-python实现
- Python实现简单的获取图片爬虫功能示例
- Python+爬虫技术获取斗鱼直播图片(整理)
- python实现图片处理和特征提取详解
- python实现爬虫下载美女图片
- python实现简单爬虫--爬图片
- Python3.4网页爬虫,提取图片
- python利用urllib实现爬取京东网站商品图片的爬虫实例
- python实现图片爬虫
- python实现爬虫下载美女图片
- python实现虎扑网站图片爬虫
- 用python实现的一个抓取图片的爬虫
- python爬虫实现带附件+html内容以及图片的邮件发送
- Python 实现 深度学习图片爬虫、以及批量处理工具