keeptabs.fetchers#
Acquiring raw items from each kind of source.
A fetcher is a function fetch(source, *, state, http_get) -> (items, state):
sourceis one normalized source record of a spec,stateis what the fetcher stored last time (validators, cursors),http_getis the one door to the network, so tests and other HTTP clients replace it with a single argument,itemsare raw item dicts with at leasturlandtitle.
DEFAULT_FETCHERS maps a source kind to its fetcher. Pass your own mapping
to keeptabs.engine.tick() to add a kind or replace one. A spec may use any
kind that has a fetcher at run time.
Everything a fetcher returns was written by other people: it is data, and it is
escaped again where it is rendered (keeptabs.digest).
Functions
|
The distinct http(s) links in a text, in order of appearance. |
|
The newest arXiv papers matching |
|
Newsletter issues in the inbox, from |
|
An RSS, Atom or JSON feed at |
|
The releases of the repository |
|
The newest Hacker News stories matching |
|
News articles matching |
|
GET a URL politely: identified, and conditional when validators are known. |
|
Readable text from an HTML fragment, with no tag left in it. |
Classes
|
What a fetcher needs from an HTTP exchange. |
- class keeptabs.fetchers.Response(status, body=b'', headers=dict())[source]#
Bases:
objectWhat a fetcher needs from an HTTP exchange.
- keeptabs.fetchers.extract_links(text)[source]#
The distinct http(s) links in a text, in order of appearance.
>>> extract_links('see https://a.example/x, and <a href="https://b.example">b</a>') ['https://a.example/x', 'https://b.example']
- Return type:
- keeptabs.fetchers.fetch_arxiv(source, *, state, http_get=<function http_get>)[source]#
The newest arXiv papers matching
source['query'](arXiv query syntax).
- keeptabs.fetchers.fetch_email(source, *, state, http_get=None, read_mail=<function _read_mail>)[source]#
Newsletter issues in the inbox, from
source['sender'](all mail if empty).Each message becomes one item, carrying the links found in its body. The cursor is the time of the newest message seen.
- keeptabs.fetchers.fetch_feed(source, *, state, http_get=<function http_get>)[source]#
An RSS, Atom or JSON feed at
source['url'].
- keeptabs.fetchers.fetch_github_releases(source, *, state, http_get=<function http_get>)[source]#
The releases of the repository
source['repo'](owner/name).
- keeptabs.fetchers.fetch_hackernews(source, *, state, http_get=<function http_get>)[source]#
The newest Hacker News stories matching
source['query'].
- keeptabs.fetchers.fetch_news_search(source, *, state, http_get=<function http_get>)[source]#
News articles matching
source['query'], through Google News RSS.
- keeptabs.fetchers.http_get(url, *, etag=None, last_modified=None, timeout=30)[source]#
GET a URL politely: identified, and conditional when validators are known.
- Return type:
- keeptabs.fetchers.strip_html(text)[source]#
Readable text from an HTML fragment, with no tag left in it.
Entities are decoded before tags are removed, so an escaped tag does not come back to life.
>>> strip_html('<p>Hello <b>world</b></p>') 'Hello world' >>> strip_html('safe <script>alert(1)</script> text') 'safe alert(1) text'
- Return type: