{"id":20049412,"url":"https://github.com/weaming/simple-crawler","last_synced_at":"2025-06-13T10:09:35.477Z","repository":{"id":52303507,"uuid":"180920544","full_name":"weaming/simple-crawler","owner":"weaming","description":"my simple crawler","archived":false,"fork":false,"pushed_at":"2022-12-08T05:55:06.000Z","size":32,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T10:07:38.453Z","etag":null,"topics":["crawler"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weaming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-12T03:07:57.000Z","updated_at":"2023-03-07T10:51:46.000Z","dependencies_parsed_at":"2023-01-24T13:45:26.600Z","dependency_job_id":null,"html_url":"https://github.com/weaming/simple-crawler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weaming/simple-crawler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsimple-crawler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsimple-crawler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsimple-crawler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsimple-crawler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaming","download_url":"https://codeload.github.com/weaming/simple-crawler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fsimple-crawler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259624725,"owners_count":22886329,"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":["crawler"],"created_at":"2024-11-13T11:49:55.463Z","updated_at":"2025-06-13T10:09:35.454Z","avatar_url":"https://github.com/weaming.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Install\n\n`pip3 install simple-crawler`\n\nSet environment `AUTO_CHARSET=1` to pass `bytes` to beautifulsoup4 and let it detect the charset.\n\n## Classes\n\n* `URL`: define a URL\n* `URLExt`: class to handle `URL`\n* `Page`: define a request result of a `URL`\n    * `url`: type `URL`\n    * `content`, `text`, `json`: response content properties from library `requests`\n    * `type`: the response body type, is a enum which allows `BYTES`, `TEXT`, `HTML`, `JSON`\n    * `is_html`: check whether is html accorrding to the response headers's `Content-Type`\n    * `soup`: `BeautifulSoup` contains html if `is_html`\n* `Crawler`: schedule the crawler by calling `handler_page()` recusively\n\n## Example\n\n```\nfrom simple_crawler import *\n\n\nclass MyCrawler(Crawler):\n    name = 'output.txt'\n    aysnc def custom_handle_page(self, page):\n        print(page.url)\n        tags = page.soup.select(\"#container\")\n        tag = tags and tags[0]\n        with open(self.name, 'a') as f:\n            f.write(tag.text)\n        # do some async call\n\n    def filter_url(self, url: URL) -\u003e bool:\n        return url.url.startswith(\"https://xxx.com/xxx\")\n\n\nloop = get_event_loop(True)\nc = MyCrawler(\"https://xxx.com/xxx\", loop, concurrency=10)\nschedule_future_in_loop(c.start(), loop=loop)\n```\n\n## TODO\n\n* [x] Speed up using async or threading\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fsimple-crawler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaming%2Fsimple-crawler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fsimple-crawler/lists"}