python在多玩图片上下载妹子图的实现代码
2013-09-08 10:04
941 查看
# -*- coding:utf-8 -*- import httplib import urllib import string import re def getContent(): #从网站中获取所有内容 conn = httplib.HTTPConnection("tu.duowan.com") conn.request("GET", "/m/meinv/index.html") r = conn.getresponse() print r.status, r.reason data1 = r.read()#.decode('utf-8') #编码根据实际情况酌情处理 return data1 def getImageUrl(data): #将获取到img链接写到sour.txt文件中国 sour = open("c:\\test\\sour.txt", 'w') pplen = len("http://s1.dwstatic.com/group1/M00/37/2A/e2c30e89184ea942a4be9c1f7ba217a5.jpg") for i in range(len(data) - 3): if data[i] == 'i' and data[i + 1] == 'm' and data[i + 2] == 'g': for j in xrange(i + 9, i + 9 + pplen): sour.write(data[j]) sour.write('\n') sour.close() def downImage(): #根据test\\sour.txt里面的url自动下载图片 tt = 0 #name sour = open('c:\\test\\sour.txt') while 1: line = sour.readline() if line: Len = len(line) print line if line[Len - 2] == 'g' and line[Len - 3] == 'p' and line[Len - 4] == 'j': path = line data = urllib.urlopen(line).read() f = open('c:\\test\\' + str(tt) + '.jpg', 'wb') f.write(data) f.close() tt = tt + 1 else: break sour.close() content = getContent() getImageUrl(content) downImage()
相关文章推荐
- python在多玩图片上下载妹子图的实现代码
- python在多玩图片上下载妹子图的实现代码
- 【教程】记录:python基础爬虫代码(下载妹子福利图片)
- 300 行 python 代码的轻量级 HTTPServer 实现文件上传下载
- Python实现的下载8000首儿歌的代码分享
- python实现爬取网站图片,视频动画到指定路径(附代码)
- python实现爬虫下载美女图片
- python实现懒加载图片的下载
- 用TreeView控件实现资源管理器(显示本地硬盘下所有文件夹和文件,并可以浏览图片)(示例代码下载)
- Python实现豆瓣图片下载的方法
- 用php实现的下载css文件中的图片的代码
- python 实现下载图片
- Shell脚本实现批量下载网络图片代码分享
- Python实现多线程下载文件的代码实例
- java实现文件上传下载和图片压缩代码示例
- 使用Python下载Bing图片(代码)
- Python3实现Web网页图片下载
- 纯代码系列:Python实现验证码图片(PIL库经典用法用法,爬虫12306思路)
- Python实现图片转字符画的示例代码
- PHP多线程批量采集下载美女图片的实现代码