Created
October 7, 2018 18:48
-
-
Save kayaked/ebe721170128e3451584f1c5718b3b12 to your computer and use it in GitHub Desktop.
My Best one line programs for Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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