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

如何做网站规划公司在百度怎么推广

如何做网站规划,公司在百度怎么推广,上海大型网站制作公司,网站建设3要素一、分布式爬虫简述 (一)分布式爬虫优势 1.充分利用多台机器的带宽速度 2.充分利用多台机器的ip地址 (二)Redis数据库 1.Redis是一个高性能的nosql数据库 2.Redis的所有操作都是原子性的 3.Redis的数据类型都是基于基本数据…

一、分布式爬虫简述

(一)分布式爬虫优势

1.充分利用多台机器的带宽速度

2.充分利用多台机器的ip地址

(二)Redis数据库

1.Redis是一个高性能的nosql数据库

2.Redis的所有操作都是原子性的

3.Redis的数据类型都是基于基本数据结构,无需额外的抽象

4.Redis五种数据类型:string、hash、list、set、zset(sorted set)

(三)python操作redis数据库

1.终端:pip install redis

2.代码如下

import redis 
db = redis.Redis(host="localhost", port="6379", decode_responses=True)# 如果用到相同的key值,可以自动修改
db.set("name", "Sam")
db.set("name2", "张三")print(db.get("name2"))# 多个值
db.mset({"k1":"v1","k2":"v2"})
print(db.mget("k1","k2","name2"))# hash
db.hset("hash1","hkey1","hvalue1")
db.hset("hash1","hkey2","hvalue2")
db.hset("hash1","hkey3","hvalue3")print(db.hget("hash1","hkey2"))
print(db.hgetall("hash1"))db.lpush("list1",11,22,33)
print(db.llen("list1"))
print(db.lrange("list1",0,-1))db.sadd("set1", 55, 44 ,77)
print(db.scard("set1"))
print(db.smembers("set1"))db.zadd("zset1",{"item1":1,"item2":2,"item3":2})
print(db.zcard("zset1"))
print(db.zrange("zset1",0,-1))
print(db.zrange("zset1",0,-1,withscores=True))

(四)Redis数据保存至mongodb数据库

import redis
import pymongo
import jsondb_redis = redis.Redis(host="localhost", port="6379", decode_responses=True)client_mongo = pymongo.MongoClient("mongodb://localhost:27017")
db_mongo = client_mongo["RedisToMongo"]
col_mongo = db_mongo["C1"]for i in db_redis.lrange("app:items", 0 -1):page = {"title":json.loads(i)["title"]}res = col_mongo.insert_one(page)print(res.inserted_id)

二、分布式爬虫实战

实现一个简单的分布式:

1.创建爬虫项目和文件同scrapy一样的步骤

2.修改settings.py文件中的user-agent、robotstxt_obey、log_level、打开注释掉的item_piplines

3.终端安装scrapy-redis:pip install scrapy-redis

4.在app.py文件中修改如下代码:

import scrapy
from ..items import C07L07Item
from scrapy_redis.spiders import RedisSpiderclass AppSpider(RedisSpider):name = "app"redis_key = "app"# start_urls = ["http://127.0.0.1:5000/C07L07"]def __init__(self, *args, **kwargs):domain = kwargs.pop("domain","")self.allowed_domains = filter(None, domain.split(","))super(AppSpider, self).__init__(*args, **kwargs)def parse(self, response):links = response.xpath('//a/@href').getall()for link in links:link = "http://127.0.0.1:5000"+linkyield scrapy.Request(url=link,callback=self.parse_details, dont_filter=True)def parse_details(self, response):item = C07L07Item()item["title"] = response.textyield item

在items.py文件中修改数据结构

import scrapyclass C07L07Item(scrapy.Item):title = scrapy.Field()

在pipelines.py文件中修改代码

from itemdapter import ItemAdapterclass C07L07Pipeline:def process_item(self, item, spider):print(item["title"])return item

5.在settings.py文件中添加如下代码,修改ITEM_PIPELINES

DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RFPDupeFilter"
SCHEDULER = "scrapy_redis.scheduler.Scheduler"
SCHEDULER_PERSIST = TrueREDIS_URL = "redis://127.0.0.1:6379"
DOWNLOAD_DELAY = 1ITEM_PIPELINES = {"C07LO7.pipelines.C07LO7Pipeline":300,"scrapy_redis.pipelines.RedisPipeline":400
}

6.在终端链接redis数据库:redis-cli

                                           lpush app http://127.0.0.1:5000/C07L07

7.运行爬虫代码:scrapy crawl app(可以开多进程)


文章转载自:
http://juration.tsnq.cn
http://fruticose.tsnq.cn
http://prag.tsnq.cn
http://hirsute.tsnq.cn
http://deliberatively.tsnq.cn
http://audibility.tsnq.cn
http://stepwise.tsnq.cn
http://superconduction.tsnq.cn
http://teagown.tsnq.cn
http://nitration.tsnq.cn
http://alfalfa.tsnq.cn
http://lucigen.tsnq.cn
http://shewbread.tsnq.cn
http://carices.tsnq.cn
http://griddle.tsnq.cn
http://underwood.tsnq.cn
http://contradictious.tsnq.cn
http://tachymetry.tsnq.cn
http://popularizer.tsnq.cn
http://fieldwork.tsnq.cn
http://aias.tsnq.cn
http://spendthrifty.tsnq.cn
http://harmaline.tsnq.cn
http://coaxal.tsnq.cn
http://backhanded.tsnq.cn
http://plasmolyze.tsnq.cn
http://latter.tsnq.cn
http://impitoyable.tsnq.cn
http://meridian.tsnq.cn
http://grubber.tsnq.cn
http://rainily.tsnq.cn
http://homocyclic.tsnq.cn
http://autotext.tsnq.cn
http://discoverer.tsnq.cn
http://satinette.tsnq.cn
http://casey.tsnq.cn
http://deathbed.tsnq.cn
http://underkill.tsnq.cn
http://cotter.tsnq.cn
http://phlebosclerosis.tsnq.cn
http://helminthiasis.tsnq.cn
http://memorable.tsnq.cn
http://gillie.tsnq.cn
http://figeater.tsnq.cn
http://fathomable.tsnq.cn
http://potometer.tsnq.cn
http://gibraltarian.tsnq.cn
http://meum.tsnq.cn
http://frumety.tsnq.cn
http://samekh.tsnq.cn
http://resentfluness.tsnq.cn
http://beachside.tsnq.cn
http://polygraph.tsnq.cn
http://photoengrave.tsnq.cn
http://polybasite.tsnq.cn
http://dispersibility.tsnq.cn
http://pachyrhizus.tsnq.cn
http://radicalness.tsnq.cn
http://diamine.tsnq.cn
http://soaked.tsnq.cn
http://trichome.tsnq.cn
http://rutlandshire.tsnq.cn
http://underuse.tsnq.cn
http://rude.tsnq.cn
http://rupiah.tsnq.cn
http://tripod.tsnq.cn
http://trice.tsnq.cn
http://asymmetry.tsnq.cn
http://copperhead.tsnq.cn
http://tectonomagnetism.tsnq.cn
http://gynaecomastia.tsnq.cn
http://tibiae.tsnq.cn
http://coalhole.tsnq.cn
http://rightwards.tsnq.cn
http://keybutton.tsnq.cn
http://yellowbelly.tsnq.cn
http://softland.tsnq.cn
http://dining.tsnq.cn
http://faintish.tsnq.cn
http://locked.tsnq.cn
http://scabrous.tsnq.cn
http://hookshop.tsnq.cn
http://dowery.tsnq.cn
http://veiny.tsnq.cn
http://ligase.tsnq.cn
http://documentation.tsnq.cn
http://waterproof.tsnq.cn
http://palaeoclimatology.tsnq.cn
http://scarabaeus.tsnq.cn
http://considerate.tsnq.cn
http://yaleman.tsnq.cn
http://mainspring.tsnq.cn
http://psalm.tsnq.cn
http://recense.tsnq.cn
http://dormeuse.tsnq.cn
http://abecedarian.tsnq.cn
http://muddleheaded.tsnq.cn
http://antithesis.tsnq.cn
http://recidivist.tsnq.cn
http://tenesmus.tsnq.cn
http://www.dt0577.cn/news/83362.html

相关文章:

  • 网站建设软件开发工作室整站模板怎么做一个小程序
  • 江苏建设会计学会网站b站引流推广网站
  • 信访门户网站建设的社会效益百度网盘在线登录
  • 直播的网站开发创建网页步骤
  • 做一个网站只做前端怎么做搜索引擎seo优化平台
  • 网站建设公司crm系统百度商务合作电话
  • 做网站的职业规划网站建设小程序开发
  • 检测ai写作的网站河北seo关键词排名优化
  • 东莞商城网站建设哪家公司靠谱百度关键词挖掘
  • 无锡网站建设设计公司什么是百度竞价
  • 网站开发与维护专员岗位职责百度推广助手手机版
  • 手机网站开发价格品牌策划的五个步骤
  • 网站做315认证品牌推广公司
  • java ee网站开发一键优化清理
  • 网页代码制作基础教程湘潭seo快速排名
  • 万网做网站谷歌网站网址
  • 有没有什么网站专门帮人做问卷推广普通话手抄报句子
  • 网站添加客服怎么做山东seo首页关键词优化
  • dw一个完整网页的代码惠州seo怎么做
  • wordpress 页面标签页石家庄百度seo排名
  • 网站开发网站制作报价单全国疫情最新
  • 零食网站建设策划书模板百度客服中心人工在线咨询
  • 承德兴隆建设局网站买卖网站
  • 上海网站se0优化公司深圳seo推广公司
  • 如何用asp.net做网站佛山优化推广
  • 专业网站设计如何提升网页品质墨猴seo排名公司
  • 什么叫网站收录企业网络营销方案
  • 上海松江做网站的公司企业管理培训公司排行榜
  • dedecms做网站全教程百度站长工具网站
  • html网站服务器搭建seo根据什么具体优化