Skip to content

Instantly share code, notes, and snippets.

@kayaked
Created October 7, 2018 18:48
Show Gist options
  • Save kayaked/ebe721170128e3451584f1c5718b3b12 to your computer and use it in GitHub Desktop.
Save kayaked/ebe721170128e3451584f1c5718b3b12 to your computer and use it in GitHub Desktop.
My Best one line programs for Python
# HTTP Status Codes
import bs4, requests;soup=bs4.BeautifulSoup(requests.get('http://httpstat.us/').text, 'html.parser'); [[soup.find_all('dt')[d].text.strip(),soup.find_all('dd')[d].text.strip()] for d in list(range(0, soup.find_all('dt').__len__()))]
# Reddit Hot Posts
import requests;[[a['data']['title'], "https://reddit.com" + a['data']['permalink'], a['data']['subreddit_name_prefixed']] for a in requests.get("https://www.reddit.com/.json", headers={'User-agent':'me'}).json()['data']['children']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment