Skip to main content

Unofficial library to get a feed of one's Pocket recommendations

Project description

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/'}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pocket-recommendations-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

pocket_recommendations-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pocket-recommendations-0.1.1.tar.gz.

File metadata

  • Download URL: pocket-recommendations-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/2.7.16 Darwin/18.7.0

File hashes

Hashes for pocket-recommendations-0.1.1.tar.gz
Algorithm Hash digest
SHA256 61d2e09d83f0d6b9916bebfe8a3de48019156964f97bb1ebb62ad8d4ef71786d
MD5 12d732744516515baa29a4f023d9e605
BLAKE2b-256 a3efa9b3df1f8589aae3e65f62119472a7f86043705942fd465b2502fb79f5be

See more details on using hashes here.

File details

Details for the file pocket_recommendations-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pocket_recommendations-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70f9970245eb12ee6740f568d4fea33ace294c4ab909a51624776faffc7b14d4
MD5 7b52eee6d56b573766cb45eb4ae0d92c
BLAKE2b-256 01371344a839f59c13b7200e1ed820cc08e54fa792e7a4b5aac3304986be5e81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page