Example #1
0
 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.")
Example #2
0
 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.")
Example #3
0
 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.")
Example #4
0
 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.")