{"id":13586521,"url":"https://github.com/alirezamika/autoscraper","last_synced_at":"2025-05-13T19:06:16.819Z","repository":{"id":40781272,"uuid":"291703561","full_name":"alirezamika/autoscraper","owner":"alirezamika","description":"A Smart, Automatic, Fast and Lightweight Web Scraper for Python","archived":false,"fork":false,"pushed_at":"2024-10-12T09:29:22.000Z","size":117,"stargazers_count":6726,"open_issues_count":0,"forks_count":703,"subscribers_count":125,"default_branch":"master","last_synced_at":"2025-04-22T17:07:33.461Z","etag":null,"topics":["ai","artificial-intelligence","automation","crawler","machine-learning","python","scrape","scraper","scraping","web-scraping","webautomation","webscraping"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"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/alirezamika.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"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},"funding":{"github":["alirezamika"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-08-31T12:02:19.000Z","updated_at":"2025-04-22T13:21:00.000Z","dependencies_parsed_at":"2024-01-14T04:26:35.228Z","dependency_job_id":"cf882128-969a-4365-bcb2-c65c28f41532","html_url":"https://github.com/alirezamika/autoscraper","commit_stats":{"total_commits":117,"total_committers":9,"mean_commits":13.0,"dds":0.2649572649572649,"last_synced_commit":"26bc6bf78a14753f5dca6856999d96d5374dc64d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alirezamika%2Fautoscraper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alirezamika%2Fautoscraper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alirezamika%2Fautoscraper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alirezamika%2Fautoscraper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alirezamika","download_url":"https://codeload.github.com/alirezamika/autoscraper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010810,"owners_count":21998993,"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":["ai","artificial-intelligence","automation","crawler","machine-learning","python","scrape","scraper","scraping","web-scraping","webautomation","webscraping"],"created_at":"2024-08-01T15:05:37.799Z","updated_at":"2025-05-13T19:06:16.774Z","avatar_url":"https://github.com/alirezamika.png","language":"Python","readme":"# AutoScraper: A Smart, Automatic, Fast and Lightweight Web Scraper for Python\n\n![img](https://user-images.githubusercontent.com/17881612/91968083-5ee92080-ed29-11ea-82ec-d99ec85367a5.png)\n\nThis project is made for automatic web scraping to make scraping easy. \nIt gets a url or the html content of a web page and a list of sample data which we want to scrape from that page. **This data can be text, url or any html tag value of that page.** It learns the scraping rules and returns the similar elements. Then you can use this learned object with new urls to get similar content or the exact same element of those new pages.\n\n\n## Installation\n\nIt's compatible with python 3.\n\n- Install latest version from git repository using pip:\n```bash\n$ pip install git+https://github.com/alirezamika/autoscraper.git\n```\n\n- Install from PyPI:\n```bash\n$ pip install autoscraper\n```\n\n- Install from source:\n```bash\n$ python setup.py install\n```\n\n## How to use\n\n### Getting similar results\n\nSay we want to fetch all related post titles in a stackoverflow page:\n\n```python\nfrom autoscraper import AutoScraper\n\nurl = 'https://stackoverflow.com/questions/2081586/web-scraping-with-python'\n\n# We can add one or multiple candidates here.\n# You can also put urls here to retrieve urls.\nwanted_list = [\"What are metaclasses in Python?\"]\n\nscraper = AutoScraper()\nresult = scraper.build(url, wanted_list)\nprint(result)\n```\n\nHere's the output:\n```python\n[\n    'How do I merge two dictionaries in a single expression in Python (taking union of dictionaries)?', \n    'How to call an external command?', \n    'What are metaclasses in Python?', \n    'Does Python have a ternary conditional operator?', \n    'How do you remove duplicates from a list whilst preserving order?', \n    'Convert bytes to a string', \n    'How to get line count of a large file cheaply in Python?', \n    \"Does Python have a string 'contains' substring method?\", \n    'Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?'\n]\n```\nNow you can use the `scraper` object to get related topics of any stackoverflow page:\n```python\nscraper.get_result_similar('https://stackoverflow.com/questions/606191/convert-bytes-to-a-string')\n```\n\n### Getting exact result\n\nSay we want to scrape live stock prices from yahoo finance:\n\n```python\nfrom autoscraper import AutoScraper\n\nurl = 'https://finance.yahoo.com/quote/AAPL/'\n\nwanted_list = [\"124.81\"]\n\nscraper = AutoScraper()\n\n# Here we can also pass html content via the html parameter instead of the url (html=html_content)\nresult = scraper.build(url, wanted_list)\nprint(result)\n```\nNote that you should update the `wanted_list` if you want to copy this code, as the content of the page dynamically changes.\n\nYou can also pass any custom `requests` module parameter. for example you may want to use proxies or custom headers:\n\n```python\nproxies = {\n    \"http\": 'http://127.0.0.1:8001',\n    \"https\": 'https://127.0.0.1:8001',\n}\n\nresult = scraper.build(url, wanted_list, request_args=dict(proxies=proxies))\n```\n\nNow we can get the price of any symbol:\n\n```python\nscraper.get_result_exact('https://finance.yahoo.com/quote/MSFT/')\n```\n\n**You may want to get other info as well.** For example if you want to get market cap too, you can just append it to the wanted list. By using the `get_result_exact` method, it will retrieve the data as the same exact order in the wanted list.\n\n**Another example:** Say we want to scrape the about text, number of stars and the link to issues of Github repo pages:\n\n```python\nfrom autoscraper import AutoScraper\n\nurl = 'https://github.com/alirezamika/autoscraper'\n\nwanted_list = ['A Smart, Automatic, Fast and Lightweight Web Scraper for Python', '6.2k', 'https://github.com/alirezamika/autoscraper/issues']\n\nscraper = AutoScraper()\nscraper.build(url, wanted_list)\n```\n\nSimple, right?\n\n\n### Saving the model\n\nWe can now save the built model to use it later. To save:\n\n```python\n# Give it a file path\nscraper.save('yahoo-finance')\n```\n\nAnd to load:\n\n```python\nscraper.load('yahoo-finance')\n```\n\n## Tutorials\n\n- See [this gist](https://gist.github.com/alirezamika/72083221891eecd991bbc0a2a2467673) for more advanced usages.\n- [AutoScraper and Flask: Create an API From Any Website in Less Than 5 Minutes](https://medium.com/better-programming/autoscraper-and-flask-create-an-api-from-any-website-in-less-than-5-minutes-3f0f176fc4a3)\n\n## Issues\nFeel free to open an issue if you have any problem using the module.\n\n\n## Support the project\n\n\u003ca href=\"https://www.buymeacoffee.com/alirezam\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-black.png\" alt=\"Buy Me A Coffee\" height=\"45\" width=\"163\" \u003e\u003c/a\u003e\n\n\n#### Happy Coding  ♥️\n","funding_links":["https://github.com/sponsors/alirezamika","https://www.buymeacoffee.com/alirezam"],"categories":["HarmonyOS","Python","网络信息服务","Web Scraping \u0026 Crawling","automation","python","🕸️ Web Scraping \u0026 Crawling"],"sub_categories":["Windows Manager","网络爬虫","Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falirezamika%2Fautoscraper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falirezamika%2Fautoscraper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falirezamika%2Fautoscraper/lists"}