Skip to content

move code all in spider.py to __init__.py #62

Description

@simonsdave

This is a very typical spider

#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-

import json
import sys

from cloudfeaster import spider

from gaming_spiders.zygomatic import ZygomaticSpider


class SolitaireOnlineSpider(ZygomaticSpider):

    @classmethod
    def get_metadata(cls):
        return {
            "url": "http://www.solitaireonline.com/?sort=mostPlayed",
        }


if __name__ == "__main__":
    crawl_args = spider.CLICrawlArgs(SolitaireOnlineSpider)
    crawler = spider.SpiderCrawler(SolitaireOnlineSpider)
    crawl_result = crawler.crawl(*crawl_args)
    print(json.dumps(crawl_result))
    sys.exit(1 if crawl_result.status_code else 0)

The from cloudfeaster import spider at the beginning and the referring to everything as spider. just feels painful. Would be much better to do a simple import cloudfeaster and then referencing everything as cloudfeaster..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions