Add print hackernews stories
This commit is contained in:
commit
ba2e2e5b08
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
TOPSTORIES=`curl -s "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"`
|
||||
URLS=""
|
||||
i=0
|
||||
n=30
|
||||
|
||||
for id in $TOPSTORIES
|
||||
do
|
||||
# First element is '[', skip it.
|
||||
if [ "$i" -eq 0 ]; then
|
||||
i=$((i+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Don't print more than n stories
|
||||
if [ "$i" -gt "$n" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
# Delete trailing comma
|
||||
storyid=`echo $id | cut -d, -f1`
|
||||
|
||||
STORY=`curl -s "https://hacker-news.firebaseio.com/v0/item/$storyid.json?print=pretty"`
|
||||
URL=`echo $STORY | jq -r '.url'`
|
||||
|
||||
URLS="$URLS $URL"
|
||||
|
||||
# TODO: filter urls
|
||||
|
||||
i=$((i+1))
|
||||
done
|
||||
|
||||
# For some fucking reason, wkhtmltopdf crashes on OpenBSD.
|
||||
wkhtmltopdf $URLS output.pdf
|
Loading…
Reference in New Issue