![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
爬虫
阿水攻城尸
一个小小的网管,没有什么抱负,只求过好自己的小日子
展开
-
python爬虫,爬取蕾丝猫美女图
# _*_ coding:utf-8 _*_import urllibimport urllib2import refrom lxml import etreeimport randomimport sys#防止中文乱码reload(sys)sys.setdefaultencoding('utf-8')#获取所有需要爬取的美女html页面def al原创 2017-09-07 14:21:57 · 10695 阅读 · 0 评论 -
mac 下运行selenium 出错解决(selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executab)
最近爬虫遇到很棘手的事情,就是遇到了动态网站。这种情况下,靠原来的抓包无法找到线索,并解决抓取问题。这时候selenium 便出现了在我的视野里面。首先是安装selenium,mac下很简单pip install Selenium==3.0.1 据说这个版本问题少安装好了 就开始学习使用它吧 1 # -*- coding: utf-8 -*- 2 from selenium import w...原创 2018-03-01 17:28:18 · 3835 阅读 · 0 评论 -
re正则在python爬虫的应用
爬虫爬多了,肯定会遇上一些需求不是在H5标签里面的东西。这时候,就只能硬着头皮去使用re正则提取东西了。import reimport urllib2from lxml import etreeins_url = 'https://www.instagram.com/ahmad_monk/'id = 22543622headers = {"User-Agent":"Mozilla/5...原创 2018-02-27 16:32:42 · 246 阅读 · 0 评论 -
scrapy 不使用ImagePipelines保存图片,并保持原图片名
除了使用自带的ImagePipelines方法外,还可以自己在pipelines写一个request,把图片保存下来。其它的都不在赘述,直接上pipelines。Pipelines.py# -*- coding: utf-8 -*-# Define your item pipelines here## Don't forget to add your pipeline to the I...原创 2018-02-09 13:51:34 · 1440 阅读 · 0 评论 -
scrapy 通过ImagePipelines下载图片并以非hash值作为图片名字来保存(保留图片原文件名)
喜欢用scrapy来爬美女图片的朋友肯定有这样的一个困扰,爬下来的图片都是各种乱码 *****.jpg 看起来不舒服,而且利于套图的归类。我就是在爬完了几十万的图片后,实在是无法忍受了,故想办法解决这个问题。首先定位到ImagePipelines.pyfrom scrapy.pipelines.images import ImagesPipelinefrom scrapy.exceptions ...原创 2018-02-09 11:58:11 · 968 阅读 · 1 评论 -
scrapy使用mongodb作为存储(数据库)
mongodb 相对于关系型数据库mysql 有不少的好处,对我而言就是在配合scrapy使用时,配置非常简单,不需要预先建表,设定字段的属性类型。 只需要在settings.py文件里面简单的配置就可以了,如下 当然,作为数据处理中心的pipelines.py也是需要做一些配置原创 2018-02-01 17:01:55 · 1349 阅读 · 1 评论 -
scrapy 模拟登录
注意:模拟登陆时,必须保证settings.py里的COOKIES_ENABLED (Cookies中间件) 处于开启状态COOKIES_ENABLED = True 或 # COOKIES_ENABLED = False策略一:直接POST数据(比如需要登陆的账户信息)只要是需要提供post数据的,就可以用这种方法。下面示例里post的数据是账户密码:# -*原创 2017-09-18 16:16:31 · 1223 阅读 · 0 评论 -
mongodb 初探
本文是本人初探mongodb的记录,高手止步原创 2017-09-18 16:11:30 · 463 阅读 · 0 评论 -
uumnt美女图片爬虫
# _*_ coding:utf-8 _*_import urllibimport urllib2import refrom lxml import etree#遍历所有471个图片页面,从中拿到每一个美女的html页面def allurl(url,headers): for a in range(1,472): Newurl = url + s原创 2017-09-07 14:40:36 · 6239 阅读 · 0 评论 -
scrapy 登陆5i5j
# -*- coding: utf-8 -*-import scrapyfrom scrapy.linkextractors import LinkExtractorfrom scrapy.spiders import CrawlSpider, Ruleclass wiwjSpider(scrapy.Spider): name = "wiwjSpider" allowed...原创 2018-04-27 16:12:20 · 284 阅读 · 0 评论