分布式脚本爬虫框架。

vredis.p的Python项目详细描述


分布式脚本爬虫框架。

# Simply connecting redis on the worker side of the library provides an-# executable power for distributed scripts# All function executions on the sender end will be piped to redis,# and the worker end will be pulled out of the pipe to execute.# Support multi-task simultaneous execution! Each execution maintains a taskid,# and different tasks maintain their configuration space according to the-# taskid when they are executed simultaneously.

工人

# if in start_worker.pyimportvrediss=vredis.Worker.from_settings(host='xx.xx.xx.xx',port=6666,password='vredis')s.start()# if in bashC:\Users\Administrator>vredisworker-hoxx.xx.xx.xx-po6666-pavredis-db0# if not set param. use defaults param.# default host localhost# default port 6379# default password None# default db 0

发件人

fromvredisimportpipepipe.connect(host='xx.xx.xx.xx',port=6666,password='vredis')pipe.DEBUG=True# True/False. worker prints on the worker_console.# very low code intrusion, no decorator or even complete barrier-free execution# The decorated function becomes a send function and is sent to the task pipeline@pipedefsome(i):importtime,randomrd=random.randint(1,2)time.sleep(rd)print('use func:{}, rd time:{}'.format(i,rd))return123# return a data and wraps them in JSON data and passes them in redis.@pipe.table('mytable')# if not set table, use "default" as tablenamedefsome2(i):print('use func2:{}'.format(i))return333,444# if return is a generator or list or tuple,# First, he iterates out the parameters and wraps them in JSON data and passes them in.# data collection space use tablename <= default tablename space "default".foriinrange(100):some(i)# first send task it will get a taskid. info will log out.some2(i)

获取数据

fromvredisimportpipepipe.connect(host='xx.xx.xx.xx',port=6666,password='vredis')foriinpipe.from_table(taskid=26):print(i)# the second param is tablename. default tablename is "default"

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Java中超类的构造函数中获取扩展泛型类的泛型类型?   java如何获取实体A的不同记录,该实体A与另一个实体B有一对多的关联,并按B记录的最新时间戳的最大值排序   JavaJSF导航参数依赖关系   具有短密文的java SecretKey匿名IBE   鼠标事件“找不到符号”错误的java解决方案   调用mediaplayer后使用java。停止我不能再发出声音了。为我解释开发参考?   java如何在序列化Avro消息时传递空值   java Sip Servlet未发送邀请请求   java根据规则访问节点,并删除链表中所有未访问的节点   Java 6上的jmockit测试用例必须使用Java代理吗?   JSF转换器f:convertDateTime是如何工作的?   java如何清除Firebase云数据库中的数组?   基于日期的列表java自定义排序   测量Java对象的内存消耗(完全“在应用程序中”)   故障终止/崩溃时的javafx Java(FX)故障保护警报?   java访问名称编码未知的文件   java如何在BlackBerry中绘制实心正方形?   java从JTextArea中删除边框   java可以使用另一个bean的属性来引用spring容器XML配置   数据透视表中具有相同列索引的java计数列