Sign inSign up

jallyhe/pyspider

By jallyhe

Updated almost 11 years ago

Pyspider

Image
2

10K+

jallyhe/pyspider repository overview

pyspider [CROTON] [![Build Status]]

Pyspider 的用法请参见 pyspider 官网文档: http://docs.pyspider.org/

CROTON 修改版支持特性

  • 一个project多schema存储支持
  • 采集结果为类型为[obj, obj, ...]支持迭代存储
  • 本地api支持操作:add/delete/hold/go/stop

详细说明

###一、operation api 说明

  • 所有操作均为:POST 操作
  • 请求URI:/task/[add:delete:hold:go:start/stop]/[taskid] ######请求参数
  • add 添加任务: {'script': #脚本内容}
  • delete 删除任务: 无参数
  • hold 暂停任务: 无参数
  • go 继续任务: 无参数
  • start 开始任务: 无参数
  • stop 停止任务: 无参数
  • 返回结果: {'result': 0 #success, 'desc': '', 'entity': #状态请求返回的字段}

######task状态获取 api 说明

  • 请求URI:/task/[taskid]
  • 返回结果: {'result': 0 #success, 'desc': '', 'entity': #状态信息字段}

###二、一个project多schema存储支持;LIST类型[obj, obj, ...]迭代类型存储支

class Handler(BaseHandler):
    @every(minutes=1)
    def on_start(self):
        self.crawl('http://edu.qq.com/l/abroad/studyabroad/lxbanli/qzbl/list20120530143633.htm', callback=self.index_page, last_modifed=False)

    @config(age=30)
    def index_page(self, response):
        for each in response.doc('a[href^="http"]').items():
            # 如果是对 LIST 里的对象迭代存储,请将 croton.schema:, 后的字段置空
            # 将需要存储的字段传入 save 参数
            # 'croton.schema:[identify], xxx' xxx 即为所需要自定义存储的schema
            # identify 是一个可以表征这个数据obj唯一性的参数,例如:'croton.schema:8295843, test_table'
            self.crawl('croton.schema:,oh_schema_XXX', callback=self.detail_page, save={'test': 'hhh'}, last_modifed=False)

    @config(priority=2)
    def detail_page(self, response, task):
        return response.save

TODO

v0.0.1
  • 功能性详细测试
  • 其他需求

Tag summary

Content type

Image

Digest

sha256:a72f30db7

Size

222.7 MB

Last updated

almost 11 years ago

docker pull jallyhe/pyspider