示例#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.")
示例#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.")
示例#3
0
文件: hnapi.py 项目: Tienenbao/pyhn
 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.")
示例#4
0
文件: hnapi.py 项目: Tienenbao/pyhn
 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.")