python scrapy重复执行实现代码详解
作者:winstonsias 时间:2023-01-15 17:27:37
这篇文章主要介绍了python scrapy重复执行实现代码详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架,我们只需要实现少量的代码,就能够快速的抓取
Scrapy模块:
1、scheduler:用来存放url队列
2、downloader:发送请求
3、spiders:提取数据和url
4、itemPipeline:数据保存
from twisted.internet import reactor, defer
from scrapy.crawler import CrawlerRunner
from scrapy.utils.log import configure_logging
import time
import logging
from scrapy.utils.project import get_project_settings
#在控制台打印日志
configure_logging()
#CrawlerRunner获取settings.py里的设置信息
runner = CrawlerRunner(get_project_settings())
@defer.inlineCallbacks
def crawl():
while True:
logging.info("new cycle starting")
yield runner.crawl("xxxxx")
#1s跑一次
time.sleep(1)
reactor.stop()
crawl()
reactor.run()
来源:https://www.cnblogs.com/winstonsias/p/12106667.html
标签:python,scrapy,重复
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Oracle分页查询的实例详解
2024-01-24 15:41:27
详解windows下vue-cli及webpack 构建网站(四) 路由vue-router的使用
2024-05-21 10:31:02
![](https://img.aspxhome.com/file/2023/2/123922_0s.png)
深入理解Django的自定义过滤器
2021-01-25 04:01:54
![](https://img.aspxhome.com/file/2023/1/71421_0s.jpg)
.NET framework 4.0 安装失败回滚问题
2023-07-11 15:50:35
![](https://img.aspxhome.com/file/2023/4/78074_0s.png)
利用Python查看目录中的文件示例详解
2023-02-06 14:13:28
小型分页的设计
2011-08-18 18:32:26
Python制作数据导入导出工具
2023-07-25 06:59:59
Javascript removeChild()删除节点及删除子节点的方法
2023-07-02 05:30:22
![](https://img.aspxhome.com/file/2023/2/137072_0s.png)
Python requests发送post请求的一些疑点
2022-09-09 17:45:03
![](https://img.aspxhome.com/file/2023/9/77609_0s.png)
Python二维列表的创建、转换以及访问详解
2022-08-09 16:03:15
使用Python中Tkinter模块的Treeview 组件显示ini文件操作
2022-05-23 03:45:38
![](https://img.aspxhome.com/file/2023/4/135084_0s.png)
Python基于机器学习方法实现的电影推荐系统实例详解
2023-09-13 17:13:41
![](https://img.aspxhome.com/file/2023/6/68406_0s.jpg)
python typing模块--类型提示支持
2023-11-11 16:47:27
![](https://img.aspxhome.com/file/2023/3/76123_0s.png)
Tornado Application的实现
2022-09-29 07:09:19
使用Pandas修改DataFrame中某一列的值
2021-04-14 14:52:21
![](https://img.aspxhome.com/file/2023/6/111866_0s.png)
Python-typing: 类型标注与支持 Any类型详解
2023-10-15 19:40:43
Python OpenCV的基本使用及相关函数
2022-11-16 11:24:55
![](https://img.aspxhome.com/file/2023/9/68819_0s.jpg)
Python 类的继承实例详解
2021-04-30 15:54:09
Webpack path与publicPath的区别详解
2024-04-29 13:37:49
Node.js原理阻塞和EventEmitter及其继承的运用实战
2024-05-05 09:21:33
![](https://img.aspxhome.com/file/2023/3/129343_0s.png)