一个简单的python爬虫,以豆瓣妹子“http://www.dbmeizi.com/category/2?p= ”为例
本想抓取网易摄影上的图,但发现查看html源代码时找不到图片的url,但firebug却能定位得到。(不知道为什么???)
目标是抓取前50页的爆乳图,代码如下:
import urllib2,urllib,re,os
'''
http://www.dbmeizi.com/category/2?p=%
'''
def get_url_from_douban():
url_list=[]
p=re.compile(r'''<img.*?src="(.+?\.jpg)''') #找出发布人的标题和url
for i in range(1,50):
target = r"http://www.dbmeizi.com/category/2?p=%d"%i
# print target
req=urllib2.urlopen(target)
result=req.read()
matchs=p.findall(result)
url_list.extend(matchs)
# print matchs
# print "-----"*40
return url_list
def download_pic(url_list):
# print url_lists
count=0
if not os.path.exists('/tmp/pic'):
os.mkdir('/tmp/pic/')
for url in url_list:
urllib.urlretrieve(url,'/tmp/pic/'+str(count)+'.jpg')
count+=1 if __name__=='__main__':
# start_time=time.time()
print "start getting url..."
url_lists=get_url_from_douban()
print "url getted! downloading..."
download_pic(url_lists)
print "download finish!!!"
# cost_time=time.time() - start_time()
# print cost_time
# download_pic(url_lists) ------------------------------------------------------------------------------
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/lsf/PycharmProjects/some_subject/get_doubanmeizi_pic.py
start getting url...
url getted! downloading...
download finish!!!
Process finished with exit code 0
运行结果如图:

只是一个简单的实现方式,没有考虑性能,速度挺慢的。
ps:贴图会不会被查水表!!??
一个简单的python爬虫,以豆瓣妹子“http://www.dbmeizi.com/category/2?p= ”为例的更多相关文章
- 一个简单的python爬虫程序
python|网络爬虫 概述 这是一个简单的python爬虫程序,仅用作技术学习与交流,主要是通过一个简单的实际案例来对网络爬虫有个基础的认识. 什么是网络爬虫 简单的讲,网络爬虫就是模拟人访问web ...
- 一个简单的python爬虫,爬取知乎
一个简单的python爬虫,爬取知乎 主要实现 爬取一个收藏夹 里 所有问题答案下的 图片 文字信息暂未收录,可自行实现,比图片更简单 具体代码里有详细注释,请自行阅读 项目源码: # -*- cod ...
- 【Python学习笔记三】一个简单的python爬虫
这里写爬虫用的requests插件 1.一般那3.x版本的python安装后都带有相应的安装文件,目录在python安装目录的Scripts中,如下: 2.将scripts的目录配置到环境变量pa ...
- 一个简单的python爬虫(转)
# -*- coding: utf-8 -*- #--------------------------------------- # 程序:百度贴吧爬虫 # 版本:0.1 # 作者:why # 日期: ...
- 一个简单的Python爬虫
写了一个抓taobao图片的爬虫,全是用if,for,while写的,比较简陋,入门作品. 从网页http://mm.taobao.com/json/request_top_list.htm?type ...
- python实现的一个简单的网页爬虫
学习了下python,看了一个简单的网页爬虫:http://www.cnblogs.com/fnng/p/3576154.html 自己实现了一个简单的网页爬虫,获取豆瓣的最新电影信息. 爬虫主要是获 ...
- Python爬虫(四)——豆瓣数据模型训练与检测
前文参考: Python爬虫(一)——豆瓣下图书信息 Python爬虫(二)——豆瓣图书决策树构建 Python爬虫(三)——对豆瓣图书各模块评论数与评分图形化分析 数据的构建 在这张表中我们可以发现 ...
- 做一个简单的scrapy爬虫
前言: 做一个简单的scrapy爬虫,带大家认识一下创建scrapy的大致流程.我们就抓取扇贝上的单词书,python的高频词汇. 步骤: 一,新建一个工程scrapy_shanbay 二,在工程中中 ...
- 作业1开发一个简单的python计算器
开发一个简单的python计算器 实现加减乘除及拓号优先级解析 用户输入 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568 ...
随机推荐
- 使用Reflexil修改类库
因为公司一个项目需要修改PPS的颜色,于是反编译了PPS的代码发现,作者很不厚道的把所有着色都HardCode在代码里 private static void InsertDefaultSeriesC ...
- 微信支付redirect_uri参数错误
在做微信支付的时候,点击提交,出现“redirect_uri参数错误”.经过查找,需要在后台正确设置授权域名.大致步骤如下:1.首先登录微信公众号管理后台2.点击开发者中心3.找到 网页账号—> ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q35-Q39)
Question 35You have a custom Web Part that is deployed as a sandboxed solution.You need to ensure th ...
- IOS开发中如何实现自动检测更新APP
自动检测更新实现逻辑: 先上github地址:https://github.com/wolfhous/HSUpdateApp 1,获取当前项目APP版本号 2,拿到AppStore项目版本号 3,对比 ...
- UnityShader之顶点片段着色器Vertex and Fragment Shader【Shader资料】
顶点片段着色器 V&F Shader:英文全称Vertex and Fragment Shader,最强大的Shader类型,也是我们在使用ShaderLab中的重点部分,属于可编程管线,使用 ...
- 选择排序(java版)
public class SelectSortTest { public static void selectSort(int[] source) { for (int i = 0; i < s ...
- android学习笔记 Service
Service(服务): 长期后台运行的没有界面的组件 android应用什么地方需要用到服务? 天气预报:后台的连接服务器的逻辑,每隔一段时间获取最新的天气信息.股票显示:后台的连接服务器的逻辑,每 ...
- Effective Java 40 Design method signatures carefully
Principle Choose method names carefully. Don't go overboard in providing convenience methods. Avoid ...
- POJ3648 A Simple Problem with Integers(线段树之成段更新。入门题)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53169 Acc ...
- 23 其它话题 - 《Python 核心编程》