Skip to content

Instantly share code, notes, and snippets.

@ksaver
Last active May 22, 2020 01:15
Show Gist options
  • Save ksaver/36c1d00d116cf19c6cd86333f3f870d2 to your computer and use it in GitHub Desktop.
Save ksaver/36c1d00d116cf19c6cd86333f3f870d2 to your computer and use it in GitHub Desktop.
Get a random command line tip from commandlinefu.com
#! /usr/bin/env python3
# clify.py
# get a random command line tip from commandlinefu.com
# usage:
# chmod +x clifu.py
# ./clifu.py
# python 2 or 3
import requests
try:
from urllib.request import Request, urlopen
except:
from urllib2 import Request, urlopen
clifu_url = "http://www.commandlinefu.com/commands/random/plaintext"
q = requests.get(clifu_url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0'})
print(q.text)
print("url:", q.url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment