perceval/backends/core/askbot.py
def get_comments(self, post_id):
        """Retrieve a list of comments by a given id.

        :param object_id: object identifiere
        """
        path = urijoin(self.base_url, self.COMMENTS if self._use_new_urls else self.COMMENTS_OLD)
        params = {
            'post_id': post_id,
            'post_type': 'answer',
            'avatar_size': 0
        }
        headers = {'X-Requested-With': 'XMLHttpRequest'}

        try:
            response = self.fetch(path, payload=params, headers=headers)
            raw = response.text
        except requests.exceptions.HTTPError as ex:
            if ex.response.status_code == 404:
                logger.debug("Comments URL did not work. Using old URL schema.")
                self._use_new_urls = False
                path = urijoin(self.base_url, self.COMMENTS_OLD)
                response = self.fetch(path, payload=params, headers=headers)
                raw = response.text
            elif ex.response.status_code == 500:
                logger.warning("Comments not retrieved due to %s", ex)
                raw = '[]'
            else:
                raise ex

        return raw
def get_comments(self, post_id):
        path = urijoin(self.base_url, self.COMMENTS if self._use_new_urls else self.COMMENTS_OLD)
        params = {
            'post_id': post_id,
            'post_type': 'answer',
            'avatar_size': 0
        }
        headers = {'X-Requested-With': 'XMLHttpRequest'}

        try:
            response = self.fetch(path, payload=params, headers=headers)
            raw = response.text
        except requests.exceptions.HTTPError as ex:
            if ex.response.status_code == 404:
                logger.debug("Comments URL did not work. Using old URL schema.")
                self._use_new_urls = False
                path = urijoin(self.base_url, self.COMMENTS_OLD)
                response = self.fetch(path, payload=params, headers=headers)
                raw = response.text
            elif ex.response.status_code == 500:
                logger.warning("Comments not retrieved due to %s", ex)
                raw = '[]'
            else:
                raise ex

        return raw
def get_comments ( self , post_id ) : path = urijoin ( self . base_url , self . COMMENTS if self . _use_new_urls else self . COMMENTS_OLD ) params = { 'post_id' : post_id , 'post_type' : 'answer' , 'avatar_size' : 0 } headers = { 'X-Requested-With' : 'XMLHttpRequest' } try : response = self . fetch ( path , payload = params , headers = headers ) raw = response . text except requests . exceptions . HTTPError as ex : if ex . response . status_code == 404 : logger . debug ( "Comments URL did not work. Using old URL schema." ) self . _use_new_urls = False path = urijoin ( self . base_url , self . COMMENTS_OLD ) response = self . fetch ( path , payload = params , headers = headers ) raw = response . text elif ex . response . status_code == 500 : logger . warning ( "Comments not retrieved due to %s" , ex ) raw = '[]' else : raise ex return raw
Retrieve a list of comments by a given id.

        :param object_id: object identifiere
Retrieve a list of comments by a given id .