alertscraper
alertscraper badge
travis badge
General purpose flexible tool for scraping a given URL for a certain type of items, and then email if new items are added. Useful for monitoring ad or auction websites. Could also be useful for setting up email alerts on your own site.
WARNING
Check the Terms of Service of the site before you use this tool! For some sites, using this tool may violate their terms of service, and should not be used.
Limitations
This code ONLY scrapes based on the initial HTTP request. Websites that function as single-page apps will not work. This could be supported in the future using JSON, or integrating with something heavier weight like Selenium.
Usage
Installation
Assuming Python’s pip is installed (for Debian-based systems, this can be installed with sudo apt-get install python-pip), alertscraper can be installed directly from PyPI:
pip install alertscraper
Python versions 3.3+ (and 2.6+) are supported and tested against.
Quick start
alertscraper is based on URLs, and maintains a history file for each URL that you scrape so it knows when something is new.
Start by navigating in your web-browser to the website you want to scrape, and then copying and pasting the URL. Then, inspect the page source of the site and see if you can figure out the DOM path to the relevant element. In this case, it was a li element with the class name result so the combined thing becomes li.result.
alertscraper 'https://some-site.org/?query=guitar&maxprice=550' li.result
This will download the given URL and list the text content of each item specified. This lets you know your query is correct.
Now we want to save this to a database file, that is, say that “I’ve seen everything currently posted and am only now interested in new stuff”.
alertscraper 'https://some-site.org/?query=guitar&maxprice=550' li.result --file=guitars.txt
Notice that it prints out again all the links it found. If we were to run the command again, it would not print them out since it will have stored them as “already seen”.
Finally, lets run the command to email us everything that has not yet been seen.
alertscraper 'https://some-site.org/?query=guitar&maxprice=550' li.result --file=guitars.txt --email=myemail@gmail.com
This only runs once. If you want it to run continually, I’d recommend putting it in a cronjob. Eventually I may add a daemon mode, but this is good for now.
Happy scraping!
Contributing
New features, tests, and bug fixes are welcome!
Metadata
Release files for alertscraper 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alertscraper-0.1.7.tar.gz | 20.1 kB | Without provenance | Details for alertscraper-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alertscraper-0.1.7-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for alertscraper-0.1.7-py2.py3-none-any.whl |
Total release size: 28.4 kB
Release files / alertscraper-0.1.7.tar.gz
| Download URL | alertscraper-0.1.7.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
704855d44a14b9833c275bb503e85d7e3fd2eeaaaa8edab67d5b6c46dea0599a
|
|
BLAKE2b-256 checksum How to use checksums |
fe671b56a087ae93225db1c849d7ecd8dbdcbe11ac471cd2531fe353217f052e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / alertscraper-0.1.7-py2.py3-none-any.whl
| Download URL | alertscraper-0.1.7-py2.py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b6d1f21d7e1a6ac906f64ce98b8ea729bc822cbc07d76d1cfc8f43d3d6684c6c
|
|
BLAKE2b-256 checksum How to use checksums |
57c7e9f44b84d727cb05e8f8d51d79da6b67810da32fdf8fcf882170e915e647
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for alertscraper 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.