pyspider 基础应用

pyspider 基础应用

系统初始示例

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2019-11-28 11:25:10
# Project: foodmate

from pyspider.libs.base_handler import *


class Handler(BaseHandler):
    crawl_config = {
    }

    @every(minutes=24 * 60)
    def on_start(self):
        self.crawl('http://down.foodmate.net/standard/sort/1/', callback=self.index_page)

    @config(age=10 * 24 * 60 * 60)
    def index_page(self, response):
        for each in response.doc('a[href^="http"]').items():
            self.crawl(each.attr.href, callback=self.detail_page)

    @config(priority=2)
    def detail_page(self, response):
        return {
            "url": response.url,
            "title": response.doc('title').text(),
        }
pyspider 基础应用

 

 

pyspider 基础应用

数据库设置

pyspider 基础应用

相关文章:

  • 2021-04-25
  • 2021-09-14
  • 2021-06-17
  • 2021-07-31
  • 2021-09-01
  • 2022-01-13
  • 2021-08-09
  • 2021-10-29
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2021-12-10
  • 2021-10-27
  • 2021-12-23
  • 2021-12-23
相关资源
相似解决方案