pocket-recommendations
Unofficial library to get a feed of one's Pocket recommendations
Usage
Get a public Pocket profile, like this one. Download its HTML using Python or anything else:
$ curl "https://getpocket.com/@honzajavorek" > getpocket-com-honzajavorek.html
In your Python program, have the HTML ready as a string:
>>> from pathlib import Path
>>> html_text = Path('getpocket-com-honzajavorek.html').read_text()
Now you can use this library to parse the HTML:
>>> import pocket_recommendations
>>> items = pocket_recommendations.parse(html_text)
>>> len(items)
50
Each item then looks like this:
>>> from pprint import pprint
>>> pprint(items[0])
{'pocket_comment': 'Šablona na váš úspěšný HackerNews post',
'pocket_recommended_at': None,
'pocket_url': 'https://getpocket.com/redirect?&url=https%3A%2F%2Fsaagarjha.com%2Fblog%2F2020%2F05%2F10%2Fwhy-we-at-famous-company-switched-to-hyped-technology%2F&h=eff6d8cac22c9b475463d037037b0efdcf44b762c9b0b7913de2104cab5fa67d',
'title': 'Why we at $FAMOUS_COMPANY Switched to $HYPED_TECHNOLOGY',
'url': 'https://saagarjha.com/blog/2020/05/10/why-we-at-famous-company-switched-to-hyped-technology/'}
Even though Pocket uses HTTP links for the redirects, the library forces HTTPS.
Date of Recommendation
You can specify the date when the HTML has been downloaded to get the relative dates when the recommendations have been posted:
>>> from datetime import date
>>> items = pocket_recommendations.parse(html_text, today=date(2020, 6, 3))
>>> pprint(items[0])
{'pocket_comment': 'Šablona na váš úspěšný HackerNews post',
'pocket_recommended_at': datetime.date(2020, 6, 2),
'pocket_url': 'https://getpocket.com/redirect?&url=https%3A%2F%2Fsaagarjha.com%2Fblog%2F2020%2F05%2F10%2Fwhy-we-at-famous-company-switched-to-hyped-technology%2F&h=eff6d8cac22c9b475463d037037b0efdcf44b762c9b0b7913de2104cab5fa67d',
'title': 'Why we at $FAMOUS_COMPANY Switched to $HYPED_TECHNOLOGY',
'url': 'https://saagarjha.com/blog/2020/05/10/why-we-at-famous-company-switched-to-hyped-technology/'}
Missing Comment
If there is no comment, it is set to None:
>>> from datetime import date
>>> items = pocket_recommendations.parse(html_text)
>>> pprint(items[15])
{'pocket_comment': None,
'pocket_recommended_at': None,
'pocket_url': 'https://getpocket.com/redirect?&url=https%3A%2F%2Falmad.blog%2Fessays%2Fwhat-is-employment%2F&h=ef4216c9df41763fa900b12815a280bf790f50960468a45ebed5f3682156dc6a',
'title': "We Don't Know What an Employment Is",
'url': 'https://almad.blog/essays/what-is-employment/'}
Misinterpreted HTML Entities
If the title contains some misinterpreted HTML entities, the library takes care of it:
>>> from datetime import date
>>> items = pocket_recommendations.parse(html_text)
>>> pprint(items[15]) # title: We Don't Know What an Employment Is
{'pocket_comment': None,
'pocket_recommended_at': None,
'pocket_url': 'https://getpocket.com/redirect?&url=https%3A%2F%2Falmad.blog%2Fessays%2Fwhat-is-employment%2F&h=ef4216c9df41763fa900b12815a280bf790f50960468a45ebed5f3682156dc6a',
'title': "We Don't Know What an Employment Is",
'url': 'https://almad.blog/essays/what-is-employment/'}
Metadata
Release files for pocket-recommendations 0.1.1
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 |
|---|---|---|---|---|
| pocket-recommendations-0.1.1.tar.gz | 3.7 kB | Without provenance | Details for pocket-recommendations-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pocket_recommendations-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pocket_recommendations-0.1.1-py3-none-any.whl |
Total release size: 7.5 kB
Release files / pocket-recommendations-0.1.1.tar.gz
| Download URL | pocket-recommendations-0.1.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61d2e09d83f0d6b9916bebfe8a3de48019156964f97bb1ebb62ad8d4ef71786d
|
|
BLAKE2b-256 checksum How to use checksums |
a3efa9b3df1f8589aae3e65f62119472a7f86043705942fd465b2502fb79f5be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/2.7.16 Darwin/18.7.0
|
Release files / pocket_recommendations-0.1.1-py3-none-any.whl
| Download URL | pocket_recommendations-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70f9970245eb12ee6740f568d4fea33ace294c4ab909a51624776faffc7b14d4
|
|
BLAKE2b-256 checksum How to use checksums |
01371344a839f59c13b7200e1ed820cc08e54fa792e7a4b5aac3304986be5e81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/2.7.16 Darwin/18.7.0
|
Security for pocket-recommendations 0.1.1
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.