hackertray/hackertray/hackernews.py

20 lines
342 B
Python
Raw Permalink Normal View History

import random
import requests
urls = [
'https://node-hnapi.herokuapp.com/'
]
class HackerNews:
2017-12-24 13:25:20 +00:00
@staticmethod
def getHomePage():
random.shuffle(urls)
for i in urls:
r = requests.get(i + "news")
try:
return r.json()
except ValueError:
2017-12-24 13:25:20 +00:00
continue