随笔分类 -  爬虫

摘要:1、etree和协程爬明朝那些事 import requestsfrom lxml import etreeimport asyncioimport aiohttpimport aiofilesimport os# 1. 拿到主页面的源代码 (不需要异步)# 2. 拿到页面源代码之后. 需要解析出 阅读全文
posted @ 2023-11-18 14:26 干it的小张 阅读(124) 评论(0) 推荐(0)
摘要:1、用bs4爬壁纸网 import requestsfrom bs4 import BeautifulSoup # 导入BeautifulSoupfrom urllib.parse import urljoin # 专门用来做url路径拼接的import timeheader = { "user-a 阅读全文
posted @ 2023-11-08 12:58 干it的小张 阅读(92) 评论(0) 推荐(0)
摘要:1、查找所有:结果 = re.findall(正则, 字符串) => 返回列表,用法:r""专业写正则的。 没有转义的烦恼,result = re.findall(r"\d+", "我有1000万,不给你花,我有1块我给你") 2、结果 = re.finditer(正则, 字符串) => 返回迭代器 阅读全文
posted @ 2023-11-08 12:30 干it的小张 阅读(239) 评论(0) 推荐(0)
摘要:import reimport urllib.request, urllib.errorimport xlwtimport sqlite3from bs4 import BeautifulSoup# 指定url内容baseurl = "https://movie.douban.com/top250? 阅读全文
posted @ 2021-01-21 01:12 干it的小张 阅读(124) 评论(0) 推荐(0)
摘要:import reimport urllib.request, urllib.errorimport xlwtfrom bs4 import BeautifulSoupbaseurl = "https://movie.douban.com/top250?start="# 创建电影链接正则表达式对象, 阅读全文
posted @ 2021-01-20 23:20 干it的小张 阅读(105) 评论(0) 推荐(0)
摘要:先来个工具操作 1、获取链接https://www.huya.com/g/xingxiu 2、删除字段、增加字段、开始采集 3、启动 4、运行中 5、采的太多了我就停止了 6、导出数据Excel格式 7、查看本地文件 8、导入到mysql数据库 9、mysql配置 10、选择导出设置 11、查看my 阅读全文
posted @ 2020-06-27 01:53 干it的小张 阅读(301) 评论(0) 推荐(0)
摘要:- 增量式 - 概念:用于监测网站数据更新的情况。 - 核心机制:去重。redis的set实现去重- 总结反爬机制: - robots - UA伪装 - 验证码 - 代理 - cookie - 动态变化的请求参数 - js加密 - js混淆 - 图片懒加载 - 动态数据的捕获 - seleium:规 阅读全文
posted @ 2020-03-08 18:45 干it的小张 阅读(165) 评论(0) 推荐(0)
摘要:- 分布式 - 概念:需要搭建一个分布式的机群,然后在机群的每一台电脑中执行同一组程序,让其对某一个网站的数据进行联合分布爬取。 - 原生的scrapy框架是不可以实现分布式? - 因为调度器不可以被共享 - 管道不可以被共享 - 如何实现分布式? - scrapy+scrapy_redis实现分布 阅读全文
posted @ 2020-03-08 12:33 干it的小张 阅读(200) 评论(0) 推荐(0)
摘要:- 图片懒加载 - 应用到标签的伪属性,数据捕获的时候一定是基于伪属性进行!!!- ImagePileline:专门用作于二进制数据下载和持久化存储的管道类- CrawlSpider - 一种基于scrapy进行全站数据爬取的一种新的技术手段。 - CrawlSpider就是Spider的一个子类 阅读全文
posted @ 2020-03-07 17:26 干it的小张 阅读(313) 评论(1) 推荐(0)
摘要:1、创建项目scrapy startproject 爬虫项目名字2、创建虫子scrapy genspider 虫名字3、setting里面加UA伪装4、加LOG_LEVEL级别、ROBOTSTXT_OBEY = False5、虫名字里面爬取网站和解析数据6、item里面增加爬取的数据7、settin 阅读全文
posted @ 2020-03-07 11:39 干it的小张 阅读(345) 评论(1) 推荐(0)
摘要:huya.py # -*- coding: utf-8 -*-import scrapyfrom huyaPro1.items import Huyapro1Itemclass HuyaSpider(scrapy.Spider): name = 'huya' # allowed_domains = 阅读全文
posted @ 2020-03-07 01:34 干it的小张 阅读(165) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*-import scrapyfrom huyaAll1.items import Huyaall1Itemclass HuyaSpider(scrapy.Spider): name = 'huya' # allowed_domains = ['www.xx 阅读全文
posted @ 2020-03-07 01:30 干it的小张 阅读(281) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*-# Define here the models for your spider middleware## See documentation in:# https://docs.scrapy.org/en/latest/topics/spider-mi 阅读全文
posted @ 2020-03-07 01:27 干it的小张 阅读(231) 评论(0) 推荐(0)
摘要:movie.py虫子 # -*- coding: utf-8 -*-import scrapyfrom moviePro1.items import Moviepro1Itemclass MovieSpider(scrapy.Spider): name = 'movie' # allowed_dom 阅读全文
posted @ 2020-03-07 01:25 干it的小张 阅读(7986) 评论(0) 推荐(0)
摘要:- 管道的持久化存储: - 数据解析(爬虫类) - 将解析的数据封装到item类型的对象中(爬虫类) - 将item提交给管道:yield item(爬虫类) - 在官大类的process_item中接收item对象并且进行任意形式的持久化存储操作(管道类) - 在配置文件中开启管道 - 细节: - 阅读全文
posted @ 2020-03-07 01:15 干it的小张 阅读(216) 评论(0) 推荐(0)
摘要:Scrapy框架的使用 - pySpider- 什么是框架? - 就是一个具有很强通用性且集成了很多功能的项目模板(可以被应用在各种需求中)- scrapy集成好的功能: - 高性能的数据解析操作(xpath) - 高性能的数据下载 - 高性能的持久化存储 - 中间件 - 全栈数据爬取操作 - 分布 阅读全文
posted @ 2020-03-06 11:19 干it的小张 阅读(178) 评论(0) 推荐(0)
摘要:import pymysqlfrom redis import Redisclass HuyaproPipeline(object): fp = None def open_spider(self, spider): print('i am open_spider()') self.fp = ope 阅读全文
posted @ 2020-02-23 15:54 干it的小张 阅读(150) 评论(0) 推荐(0)
摘要:import scrapyfrom firstBlood.items import FirstbloodItemclass FirstSpider(scrapy.Spider): 爬虫文件的名称:爬虫源文件的唯一标识 name = 'first' 允许的域名: allowed_domains = [ 阅读全文
posted @ 2020-02-23 15:53 干it的小张 阅读(271) 评论(0) 推荐(0)
摘要:Scrapy框架的使用 - pySpider- 什么是框架? - 就是一个具有很强通用性且集成了很多功能的项目模板(可以被应用在各种需求中)- scrapy集成好的功能: - 高性能的数据解析操作(xpath) - 高性能的数据下载 - 高性能的持久化存储 - 中间件 - 全栈数据爬取操作 - 分布 阅读全文
posted @ 2020-02-23 15:46 干it的小张 阅读(107) 评论(0) 推荐(0)
摘要:Selenium 在被使用的时候有个麻烦事,就是环境的相关配置,得安装好相关浏览器,比如 Chrome、Firefox 等等,然后还要到官方网站去下载对应的驱动,最重要的还需要安装对应的 Python Selenium 库,确实是不是很方便,另外如果要做大规模部署的话,环境配置的一些问题也是个头疼的 阅读全文
posted @ 2020-02-22 21:09 干it的小张 阅读(439) 评论(0) 推荐(0)