12345678910111213141516171819202122232425262728293031 |
- import os
- from pprint import pprint as pp
- from pocket import Pocket, PocketException
- if __name__ == '__main__':
- p = Pocket(
- consumer_key=os.environ.get('POCKET_CONSUMER_KEY', ''),
- access_token=os.environ.get('POCKET_ACCESS_TOKEN', ''),
- )
- # Fetch a list of articles
- try:
- fetch_more = True
- offset = 0
- count = 10
- while fetch_more:
- items = p.retrieve(favorite=True, offset=offset, count=count)
- try:
- for item_id, item in items['list'].items():
- if not item['resolved_url']:
- continue
- print(item['resolved_url'])
- offset += count
- except AttributeError:
- fetch_more = False
- except PocketException as e:
- print(e.message)
|