妹子图XXOO
来源:互联网 发布:excel 数据清洗 编辑:程序博客网 时间:2024/04/29 20:48
依葫芦画瓢
用字符串查找图片地址下载
图片放在当前目录
GIF下载下来不会动.....
import urllib.requestimport timedef open_url(url): #return htmlpage print(url) req = urllib.request.Request(url) req.add_header("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36") response = urllib.request.urlopen(req) return response.read()def getInitialpage(): #return how many pages we have url = "http://jandan.net/ooxx" html = open_url(url) html = html.decode("utf-8") index = html.find("span class=\"current-comment-page\"") beginindex = html.find("[" , index) endindex = html.find("]" , index) initialpage = html[(beginindex+1) : endindex] return initialpagedef getpiclist(pageurl): html = open_url(pageurl) html = html.decode("utf-8") piclist = list() for i in range(html.count("[查看原图]</a><br /><img")): index = html.find("[查看原图]</a><br /><img") html=html[index:] beginindex = html.find("\"") endindex = html.find("\"" , (beginindex+1)) picurl = html[beginindex+1:endindex] html = html[endindex:] piclist.append(picurl) return piclistdef savepic(piclist): for picurl in piclist: html = open_url("http:{}".format(picurl)) filename = picurl.split("/")[-1] print(filename) with open(filename , "wb") as f: f.write(html) time.sleep(1)def test(page): initialpage = int(getInitialpage()) for i in range((initialpage-page),(initialpage+1)): pageurl = "http://jandan.net/ooxx/page-{}#comments".format(i) piclist = getpiclist(pageurl) savepic(piclist) if __name__ == "__main__": test(1)
阅读全文
0 0
- 妹子图XXOO
- XXOO
- xxoo
- 妹子图
- 萌妹子图一张
- 妹子图 Spider
- NodeJs妹子图爬虫
- NodeJS-妹子图爬虫
- 爬虫 妹子图
- 抓取妹子图
- Python抓取妹子图
- 妹子!
- Python3抓取煎蛋妹子图
- Python3 实现妹子图爬虫
- 简单爬取妹子图
- 煎蛋网妹子图爬虫
- 菜鸟爬虫-爬妹子图
- Python 爬取妹子图
- 队列的基本操作 数据结构
- Lintcode最长单词
- 第五周编程题_多项式加法
- 南理工2016考研复试上机题男女程序员排队
- (简单)宏定义 与 用户自定义类型typedef
- 妹子图XXOO
- Graph Theory NO.1 HDU_1213_How Many Tables_并查集
- LazyInitializationException 懒加载异常的四种解决方案
- 九度OJ——1019简单计算器
- POJ 1515 浅谈无向图边双连通分量Tarjan求法
- 不同BIOS下的U盘启动设置方法
- Matlab 的动态曲线绘图
- 基于VC 6.0 开发的MFC程序如何在文件资源管理器中浏览并选中操作文件
- Qt之右键弹出菜单