def getComments(self): url = ('http://hndroidapi.appspot.com/' 'nestedcomments/format/json/id/%s' % self.id) try: r = requests.get(url, headers=HEADERS) self.comments = r.json()['items'] return self.comments except Exception: raise HNException( "Error getting source from " + url + ". Your internet connection may have something funny " "going on, or you could be behind a proxy.")
def getSource(self, url): """ Returns the HTML source code for a URL. """ try: r = requests.get(url, headers=HEADERS) if r: return r.text except Exception: raise HNException( "Error getting source from " + url + ". Your internet connection may have something " "funny going on, or you could be behind a proxy.")
def getComments(self): url = ( 'http://hndroidapi.appspot.com/' 'nestedcomments/format/json/id/%s' % self.id) try: r = requests.get(url, headers=HEADERS) self.comments = r.json()['items'] return self.comments except Exception: raise HNException( "Error getting source from " + url + ". Your internet connection may have something funny " "going on, or you could be behind a proxy.")