上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
摘要: 使得mongodb具备自动故障转移、高可用、读写分离。 副本集默认情况下读写都只是通过主库,副节点只是备份数据而已,但是可以设置副节点允许读操作,这样就可以做成读写分离。 使用pymongo的时候也可以设置,还可以动态设置库、集合的readPreference。详细的后面再写。。。 如果主节点不可用 阅读全文
posted @ 2023-07-17 11:58 蕝戀 阅读(116) 评论(0) 推荐(0) 编辑
摘要: ## 读写分离 默认情况下,MongoClient 实例将查询发送到副本集的主要成员。 要使用副节点作为查询,以实现读写分离,我们必须更改读取首选项: 读取首选项在模块`pymongo.ReadPreference`下: - PRIMARY: 从主节点中读取(默认) - PRIMARY_PREFER 阅读全文
posted @ 2023-07-17 11:56 蕝戀 阅读(90) 评论(0) 推荐(0) 编辑
摘要: [https://pymongo.readthedocs.io/en/stable/examples/high_availability.html#](https://pymongo.readthedocs.io/en/stable/examples/high_availability.html#) 阅读全文
posted @ 2023-07-17 11:55 蕝戀 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 使用pymongo,具体可以参考官方文档: 语法上基本和原生mongodb是一样的,所以非常容易入手... [https://pymongo.readthedocs.io/en/stable/tutorial.html](https://pymongo.readthedocs.io/en/stabl 阅读全文
posted @ 2023-07-17 11:54 蕝戀 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 命令参考:[https://github.com/scrapy/scrapyd-client](https://github.com/scrapy/scrapyd-client) [https://scrapyd.readthedocs.io](https://scrapyd.readthedocs 阅读全文
posted @ 2023-07-17 11:49 蕝戀 阅读(76) 评论(0) 推荐(0) 编辑
摘要: scrapy本身是自带支持HTTP2的爬取: [https://docs.scrapy.org/en/latest/topics/settings.html?highlight=H2DownloadHandler#download-handlers-base](https://docs.scrapy 阅读全文
posted @ 2023-07-17 11:47 蕝戀 阅读(130) 评论(0) 推荐(0) 编辑
摘要: **高级方法:** **一般方法:** 运行爬虫时使用-a传递参数 ```Bash scrapy crawl 爬虫名 -a key=values ``` 然后在爬虫类的__init__魔法方法中获取kwargs ```Python class Bang123Spider(RedisCrawlSpid 阅读全文
posted @ 2023-07-17 11:44 蕝戀 阅读(16) 评论(0) 推荐(0) 编辑
摘要: settings.py中设置配置项 ```Python MONGODB_HOST = "127.0.0.1" MONGODB_PORT = 27017 MONGODB_DB_NAME = "bang123" ``` pipelines.py: ```Python from scrapy.pipeli 阅读全文
posted @ 2023-07-17 11:44 蕝戀 阅读(9) 评论(0) 推荐(0) 编辑
摘要: scrapy特性就是效率高,异步,如果非要集成selenium实际上意义不是特别大....因为selenium慢.... 案例:淘宝首页推荐商品的标题获取 爬虫类 toabao.py ```Python import scrapy from scrapy.http import HtmlRespon 阅读全文
posted @ 2023-07-17 11:42 蕝戀 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 安装包 ```Python pip install -U scrapy-redis ``` settings.py ```Python ##### Scrapy-Redis ##### ### Scrapy指定Redis 配置 ### # 其他默认配置在scrapy_redis.default.py 阅读全文
posted @ 2023-07-17 11:40 蕝戀 阅读(30) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页