{"id":22139953,"url":"https://github.com/daringer/lollygag","last_synced_at":"2025-03-24T10:43:35.386Z","repository":{"id":73629368,"uuid":"105471520","full_name":"daringer/lollygag","owner":"daringer","description":"Simple base for web scrapers","archived":false,"fork":false,"pushed_at":"2017-11-12T04:00:36.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T16:11:32.710Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daringer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-01T20:19:20.000Z","updated_at":"2018-06-21T00:21:11.000Z","dependencies_parsed_at":"2023-09-02T02:28:33.142Z","dependency_job_id":null,"html_url":"https://github.com/daringer/lollygag","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daringer%2Flollygag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daringer%2Flollygag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daringer%2Flollygag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daringer%2Flollygag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daringer","download_url":"https://codeload.github.com/daringer/lollygag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245257310,"owners_count":20585971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T20:20:54.050Z","updated_at":"2025-03-24T10:43:35.360Z","avatar_url":"https://github.com/daringer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lollygag\n\n## About\n\n* Travis CI: [![Build Status](https://travis-ci.org/snorrwe/lollygag.svg?branch=master)](https://travis-ci.org/snorrwe/lollygag)\n* Supported Python versions: \n    * Python 2.7\n    * Python 3.6\n    * Pypy\n    * Pypy 3\n\n## Installation\n\n`pip install lollygag`\n\n## Usage\n\n1. Create a custom _Parser_ to define behaviour\n1. Configure the _Crawler_ via either the _run_ method or command line arguments\n1. Run your script `python my_crawler.py`\n\n### Sample code\n\nFind the source code [here](https://github.com/snorrwe/lollygag/blob/master/examples/daringer_example.py)\n\n```python\nfrom lollygag import run, Services, LinkParser, DomainCrawler, Crawler\n\n\nclass MyParser(LinkParser):\n    def __init__(self, *args, **kwargs):\n        super(MyParser, self).__init__(*args, **kwargs)\n        self.use_next_data = False\n\n    # on new page is found and shall be processed, 'data' contains full html-source\n    def feed(self, data):\n        return super(MyParser, self).feed(data)\n\n    # on each start-tag found inside the full html-source\n    def handle_starttag(self, tag, attrs):\n        # super() will handle links (\u003ca\u003e) parsing, you can add() arbitrary links to self._links\n        super(MyParser, self).handle_starttag(tag, attrs)\n\n        # for \u003cscript\u003e the contents are needed, set flag to remember it\n        if tag == \"script\":\n            self.use_next_data = True\n        if tag == \"img\":\n            self.log_service.info(\"found img: {}\".format(dict(attrs).get(\"src\", \"\u003cno src attr\u003e\")))\n\n    # on each data (between two tags)\n    def handle_data(self, data):\n        if self.use_next_data:\n            self.log_service.info(\"script contents: {}\".format(data))\n\n    # on each end-tag found\n    def handle_endtag(self, tag):\n        if tag == \"script\":\n            self.use_next_data = False\n\n\n# `Services.site_parser_factory` defines how a single page is parsed\nServices.site_parser_factory = MyParser\n\n# `Services.crawler_factory` defines the Crawler, thus how links are handled (where to crawl?)\n# - By default `DomainCrawler` is used, which restricts crawling to _one_ domain\n# - You \"might\" put `Crawler` here, this will lead to endless crawling...\n# Services.crawler_factory = Crawler\nrun()\n```\n\n### Command line arguments\n\n\u003ctable\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eName\u003c/th\u003e\n            \u003cth\u003eShort\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n            \u003cth\u003eDefault\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n        \u003cdiv\u003e\n            \u003ctr\u003e\n                \u003ctd\u003e--help\u003c/td\u003e\n                \u003ctd\u003e-h\u003c/td\u003e\n                \u003ctd rowspan=\"2\"\u003eShow the help and exit\u003c/td\u003e\n                \u003ctd\u003e - \u003c/td\u003e\n            \u003c/tr\u003e\n            \u003ctr\u003e\n            \u003c/tr\u003e\n        \u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ctr\u003e\n                \u003ctd\u003e--url\u003c/td\u003e\n                \u003ctd\u003e-u\u003c/td\u003e\n                \u003ctd rowspan=\"2\"\u003eBase url you wish to crawl.\u003cbr\u003e\n                \u003ci\u003e\n                    Note that if you pass the url argument to run() or crawl_domain() this option will be ignored.\n                \u003c/i\u003e\n                \u003c/td\u003e\n                \u003ctd\u003e None \u003c/td\u003e\n            \u003c/tr\u003e\n            \u003ctr\u003e\n            \u003c/tr\u003e\n        \u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ctr\u003e\n                \u003ctd\u003e--threads\u003c/td\u003e\n                \u003ctd\u003e-t\u003c/td\u003e\n                \u003ctd rowspan=\"2\"\u003eMaximum number of concurrent threads\u003c/td\u003e\n                \u003ctd\u003e 5 \u003c/td\u003e\n            \u003c/tr\u003e\n            \u003ctr\u003e\n            \u003c/tr\u003e\n        \u003c/div\u003e\n        \u003cdiv\u003e\n            \u003ctr\u003e\n                \u003ctd\u003e--loglevel\u003c/td\u003e\n                \u003ctd\u003e-l\u003c/td\u003e\n                \u003ctd rowspan=\"2\"\u003eLevel of logging, possible values = [all, debug, info, warn, error, none]\u003c/td\u003e\n                \u003ctd\u003e all \u003c/td\u003e\n            \u003c/tr\u003e\n            \u003ctr\u003e\n            \u003c/tr\u003e\n        \u003c/div\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Contributing\n\nPlease refer to the [contribution guidelines](https://github.com/snorrwe/lollygag/blob/master/.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](https://github.com/snorrwe/Crawler/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaringer%2Flollygag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaringer%2Flollygag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaringer%2Flollygag/lists"}