]> git.armaanb.net Git - bin.git/blobdiff - tweet-cgi
tweet-cgi: convert to CGI script from tweet-grab
[bin.git] / tweet-cgi
diff --git a/tweet-cgi b/tweet-cgi
new file mode 100755 (executable)
index 0000000..d63f8f3
--- /dev/null
+++ b/tweet-cgi
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+# Grabs a tweet form a user and display it. Avoids using the twitter
+# API by scrapping a nitter instance, which can easily be scraped,
+# unlike the intentionally crippled twitter.com. Powers
+# https://ishaan.bhojwani.org
+
+INSTANCE=${INSTANCE:-https://nitter.fdn.fr}
+USER=${USER:-keshinko}
+
+printf "Content-type: text/plain\n\n"
+curl -s "$INSTANCE/$USER" | grep tweet-content | head -n 1 \
+               | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*\(.*$\)/\1/'