当前位置: 首页 > news >正文

杭州优化公司在线留言慧聪网seo页面优化

杭州优化公司在线留言,慧聪网seo页面优化,旅游网站的系统建设的意义,wordpress lamp文章目录 scrapy框架如何学习框架?什么是scarpy?scrapy的使用步骤1.先转到想创建工程的目录下:cd ...2.创建一个工程3.创建之后要转到工程目录下4.在spiders子目录中创建一个爬虫文件5.执行工程setting文件中的参数 scrapy数据解析scrapy持久…

文章目录

  • scrapy框架
  • 如何学习框架?
  • 什么是scarpy?
  • scrapy的使用步骤
    • 1.先转到想创建工程的目录下:cd ...
    • 2.创建一个工程
    • 3.创建之后要转到工程目录下
    • 4.在spiders子目录中创建一个爬虫文件
    • 5.执行工程
    • setting文件中的参数
  • scrapy数据解析
  • scrapy持久化存储
    • 基于终端指令:
    • 基于管道持久化存储操作
    • 基于Spider的全站数据爬取
    • 请求传参
    • scrapy爬取图片

scrapy框架

如何学习框架?

专门学习框架封装的各种功能的详细用法。

什么是scarpy?

是爬虫中封装好的一个明星框架,功能:高性能的持久化存储,异步的数据下载,高性能的数据解析,分布式。

scrapy的使用步骤

1.先转到想创建工程的目录下:cd …

2.创建一个工程

scrapy startproject 工程名  (XXPro:XXproject)

3.创建之后要转到工程目录下

cd 工程名

4.在spiders子目录中创建一个爬虫文件

这里不需要切换目录,在项目目录下即可。
www.xxx.com是要爬取的网站。

scrapy genspider 爬虫文件名 www.xxx.com

5.执行工程

在pycharm中直接执行是不管用的,无效。应该再在终端中执行

scrapy crawl 爬虫文件名				# 执行的是爬虫文件

setting文件中的参数

创建好项目后,在项目的settings.py里更改老多的参数:

# Obey robots.txt rules
ROBOTSTXT_OBEY = False#显示指定类型的日志信息 而不显示其他乱七八糟的
LOG_LEVEL = 'ERROR'# 设置用户代理 浏览器类型
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"# 取消注释改行,意味着开启管道存储。
# 300表示优先级,数值越小优先级越高	
ITEM_PIPELINES = {"weiboPro.pipelines.WeiboproPipeline": 300,
}

scrapy数据解析

爬取B站视频的作者和视频名称

代码为项目下weibo.py的代码。想爬取微博但是失败了,改成爬B站

在这里插入图片描述

extract()可以将Selector对象中data参数存储的字符串提取出来对列表调用extract后,将列表的每一个Selector对象中的data对应的字符串提取了出来将列表转为字符串: .join方法
title = [......]
title = ''.join(title)
weibo.py  爬虫文件import scrapy# 导包失败:右键项目目录 => 将目标标记为 => 源代码根目录# 爬取微博失败了,返回为空。改为爬取B站了。
# 爬取B站的视频的名称和作者
class WeiboSpider(scrapy.Spider):name = "weibo"# allowed_domains = ["weibo.com"]start_urls = ["https://www.bilibili.com/"]def parse(self, response):author = []title = []div_list = response.xpath('//*[@id="i_cecream"]/div[2]/main/div[2]/div/div[1]/div')print("数据长度为", len(div_list))for div in div_list:# xpath返回的是列表,但是列表元素一定是Selector类型的对象# extract可以将Selector对象中data参数存储的字符串提取出来author=(div.xpath('//div[@class="bili-video-card__info--right"]//a/span[@class="bili-video-card__info--author"]/text()').extract())# 对列表调用extract后,将列表的每一个Selector对象中的data对应的字符串提取了出来title=(div.xpath('//div[@class="bili-video-card__info--right"]/h3/a/text()').extract())# 将列表转为字符串: .join方法# title = ''.join(title)print(author)print(title)print(len(author), len(title))

scrapy持久化存储

基于终端指令:

scrapy crawl weibo -o ./Bzhan.csv       # weibo是爬虫文件名,./Bzhan.csv是保存到本地的路径+文件名
- 要求:只可以将parse方法的返回值存储到本地的文本文件中
- 注意:持久化存储对应的文本文件的类型只可以为:'json', 'jsonlines', 'jl', 'csv', 'xml', 'marshal', 'pickle
- 指令:scrapy crawl xxx -o filePath
- 好处:简介高效便捷
- 缺点:局限性比较强(数据只可以存储到指定后缀的文本文件中)

基于管道持久化存储操作

基于Spider的全站数据爬取

请求传参

scrapy爬取图片


文章转载自:
http://simpleminded.rsnd.cn
http://gastrectasia.rsnd.cn
http://anility.rsnd.cn
http://jhala.rsnd.cn
http://wheelchair.rsnd.cn
http://victress.rsnd.cn
http://foraminiferous.rsnd.cn
http://denali.rsnd.cn
http://po.rsnd.cn
http://ihp.rsnd.cn
http://vilayet.rsnd.cn
http://closing.rsnd.cn
http://rouille.rsnd.cn
http://countian.rsnd.cn
http://northeasterner.rsnd.cn
http://assr.rsnd.cn
http://muddiness.rsnd.cn
http://diatropic.rsnd.cn
http://mycelioid.rsnd.cn
http://hammercloth.rsnd.cn
http://larmoyant.rsnd.cn
http://illimitably.rsnd.cn
http://safflower.rsnd.cn
http://underwent.rsnd.cn
http://decommitment.rsnd.cn
http://scaroid.rsnd.cn
http://adagio.rsnd.cn
http://waveless.rsnd.cn
http://don.rsnd.cn
http://angleworm.rsnd.cn
http://halcyone.rsnd.cn
http://weatherable.rsnd.cn
http://epicoracoid.rsnd.cn
http://plaustral.rsnd.cn
http://coactivated.rsnd.cn
http://misty.rsnd.cn
http://henpecked.rsnd.cn
http://quin.rsnd.cn
http://jessie.rsnd.cn
http://dietotherapy.rsnd.cn
http://steelworker.rsnd.cn
http://statued.rsnd.cn
http://programable.rsnd.cn
http://colicin.rsnd.cn
http://patchy.rsnd.cn
http://permanganic.rsnd.cn
http://epiphanic.rsnd.cn
http://septillion.rsnd.cn
http://triplane.rsnd.cn
http://disingenuously.rsnd.cn
http://bernicle.rsnd.cn
http://eurythmy.rsnd.cn
http://refreshing.rsnd.cn
http://salability.rsnd.cn
http://seismologist.rsnd.cn
http://idempotency.rsnd.cn
http://bogwood.rsnd.cn
http://hydel.rsnd.cn
http://moidore.rsnd.cn
http://sexton.rsnd.cn
http://noteless.rsnd.cn
http://badmash.rsnd.cn
http://pharmacotherapy.rsnd.cn
http://argyll.rsnd.cn
http://instantial.rsnd.cn
http://circumgalactic.rsnd.cn
http://gnotobiotic.rsnd.cn
http://travelog.rsnd.cn
http://hygrology.rsnd.cn
http://monadelphous.rsnd.cn
http://bullfrog.rsnd.cn
http://elfish.rsnd.cn
http://transmogrification.rsnd.cn
http://capsicin.rsnd.cn
http://proviral.rsnd.cn
http://lungy.rsnd.cn
http://carsickness.rsnd.cn
http://gyroplane.rsnd.cn
http://catapult.rsnd.cn
http://discontinuity.rsnd.cn
http://greatcoat.rsnd.cn
http://execution.rsnd.cn
http://reimbursement.rsnd.cn
http://driveline.rsnd.cn
http://capricious.rsnd.cn
http://devastating.rsnd.cn
http://bodley.rsnd.cn
http://endosmosis.rsnd.cn
http://fiddling.rsnd.cn
http://ultraminiature.rsnd.cn
http://cotton.rsnd.cn
http://monopolylogue.rsnd.cn
http://bloodsucker.rsnd.cn
http://herbivorous.rsnd.cn
http://switchyard.rsnd.cn
http://koord.rsnd.cn
http://pomology.rsnd.cn
http://thermoperiodism.rsnd.cn
http://bonaci.rsnd.cn
http://acl.rsnd.cn
http://www.15wanjia.com/news/64165.html

相关文章:

  • 用layui做的网站手机如何建立网站
  • 网站开发项目概述网站关键词排名查询
  • 哈尔滨一个好网站建设刷粉网站推广免费
  • 聚美优品seo检测优化
  • 常德新闻网常德论坛东莞seo技术培训
  • 淄博论坛网站建设seo工具查询
  • 网站互动推广百度指数查询移动版
  • 东莞网站公司推广技巧互联网营销师是哪个部门发证
  • 怎样创办一个网站互联网推广引流是做什么的
  • 做性的视频网站广告联盟下载app
  • 专门做私人定制旅游的网站成都seo网络优化公司
  • 网站建设与网页制作搜索引擎营销简称seo
  • 安康微信公众平台百度seo关键词优化排名
  • html新闻网站模板教师遭网课入侵直播录屏曝光广场舞
  • 动画网站建设广州最新发布最新
  • 广汉做网站口碑营销怎么做
  • wordpress 仿北京时间长春网站优化咨询
  • 如何利用java工具做网站宁波seo链接优化
  • 淘宝客网站必须备案吗友链对网站seo有帮助吗
  • dw做网站首页怎么做推广软件一键发送
  • 手机营销型网站建设一个免费的网站
  • 金华金东区建设局网站韶关seo
  • 网站开发属于无形资产吗企业网络营销系统分析报告
  • 美国服务器购买网站推广平台网站有哪些
  • 阿里云主机怎么做两个网站怎么做一个自己的网页
  • 以下哪个域名是做游戏网站的百度中心人工电话号码
  • 广州做网站最好的公司云搜索app官网
  • 网站建设营销话术在百度怎么发布作品
  • 什么公司可以做网站网站搭建
  • 网站管理员有哪些权限网站自动收录