Skip to main content

dlhn is a Python CLI script to download my comments and submissions from the Hacker News API and generate a static HTML archive with a Jinja2 template

Project description

dlhn

https://img.shields.io/pypi/v/dlhn.svg https://img.shields.io/travis/westurner/dlhn.svg

dlhn is a Python CLI script to download my comments and submissions from the Hacker News API and generate a static HTML archive with a Jinja2 template

Features

  • Download comments and submissions from the Hacker News API

  • Archive comment trees and submissions as JSON

  • Archive comment trees and submissions as static HTML with a Jinja2 HTML template

  • Aggressively cache entries that couldn’t have changed with a two-layer caching system that includes requests_cache and a sqlite database

Installation

Install dlhn with pip:

pip install dlhn

# pip install -e git+https://github.com/westurner/dlhn#egg=dlhn

Usage

Call dlhn:

dlhn -u dlhntestuser -o index.html --expire-newerthan 14d

Optionally, create a repo for e.g. GitHub Pages and add a Makefile:

# hnlog Makefile

USERNAME:=dlhntestuser

default: backup

install:
    pip install -e git+https://github.com/westurner/dlhn#egg=dlhn

backup:
    @# items with a cachetime newer than 14d ago may need to be pulled again
    @# because they may not be locked yet (cachetime != item_time)
    dlhn -u '$(USERNAME)' -o index.html --expire-newerthan 14d

backup-nocache:
    dlhn -u '$(USERNAME)' -o index.html

commit:
    git add ./index.html ./index.html.json ./dlhn.sqlite && \
    git commit -m ":books: Updated index.html, index.html.json, and dlhn.sqlite"

push:
    git push

all: backup commit push

And pass USERNAME as an arg when calling make:

make all USERNAME=dlhntestuser

References

License

BSD License

dlhn archives pubicly available comments and submissions from the Hacker News API for noncommercial use to make searching one-page with ‘Ctrl-F’ easy.

Credits

History

0.2.5 (2019-04-17)

  • Update README.rst

0.2.4 (2019-04-17)

  • Update docs with pip package name

  • Update HISTORY.rst

0.2.3 (2019-04-17)

  • Add a setup.py

  • Add a few tests

  • First release on PyPI.

0.1.0 (2017-11-28)

  • Simple python script

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

dlhn-0.2.5.tar.gz (15.4 kB view hashes)

Uploaded Source

Built Distribution

dlhn-0.2.5-py2.py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 2 Python 3

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