def get_http_raw(self, url=None, retry_count=3, headers=None,
                     request_type='GET', form_data=None):
        """
        The function for retrieving a raw HTML result via HTTP.

        Args:
            url (:obj:`str`): The URL to retrieve (required).
            retry_count (:obj:`int`): The number of times to retry in case
                socket errors, timeouts, connection resets, etc. are
                encountered. Defaults to 3.
            headers (:obj:`dict`): The HTTP headers. The Accept header
                defaults to 'text/html'.
            request_type (:obj:`str`): Request type 'GET' or 'POST'. Defaults
                to 'GET'.
            form_data (:obj:`dict`): Optional form POST data.

        Returns:
            str: The raw data.

        Raises:
            HTTPLookupError: The HTTP lookup failed.
        """

        if headers is None:
            headers = {'Accept': 'text/html'}

        enc_form_data = None
        if form_data:
            enc_form_data = urlencode(form_data)
            try:
                # Py 2 inspection will alert on the encoding arg, no harm done.
                enc_form_data = bytes(enc_form_data, encoding='ascii')
            except TypeError:  # pragma: no cover
                pass

        try:

            # Create the connection for the HTTP query.
            log.debug('HTTP query for {0} at {1}'.format(
                self.address_str, url))
            try:
                # Py 2 inspection alert bypassed by using kwargs dict.
                conn = Request(url=url, data=enc_form_data, headers=headers,
                               **{'method': request_type})
            except TypeError:  # pragma: no cover
                conn = Request(url=url, data=enc_form_data, headers=headers)
            data = self.opener.open(conn, timeout=self.timeout)

            try:
                d = data.readall().decode('ascii', 'ignore')
            except AttributeError:  # pragma: no cover
                d = data.read().decode('ascii', 'ignore')

            return str(d)

        except (URLError, socket.timeout, socket.error) as e:

            log.debug('HTTP query socket error: {0}'.format(e))
            if retry_count > 0:

                log.debug('HTTP query retrying (count: {0})'.format(
                    str(retry_count)))

                return self.get_http_raw(
                    url=url, retry_count=retry_count - 1, headers=headers,
                    request_type=request_type, form_data=form_data
                )

            else:

                raise HTTPLookupError('HTTP lookup failed for {0}.'.format(
                    url))

        except HTTPLookupError as e:  # pragma: no cover

            raise e

        except Exception:  # pragma: no cover

            raise HTTPLookupError('HTTP lookup failed for {0}.'.format(url))
def get_http_raw ( self , url = None , retry_count = 3 , headers = None , request_type = 'GET' , form_data = None ) : if headers is None : headers = { 'Accept' : 'text/html' } enc_form_data = None if form_data : enc_form_data = urlencode ( form_data ) try : enc_form_data = bytes ( enc_form_data , encoding = 'ascii' ) except TypeError : pass try : log . debug ( 'HTTP query for {0} at {1}' . format ( self . address_str , url ) ) try : conn = Request ( url = url , data = enc_form_data , headers = headers , ** { 'method' : request_type } ) except TypeError : conn = Request ( url = url , data = enc_form_data , headers = headers ) data = self . opener . open ( conn , timeout = self . timeout ) try : d = data . readall ( ) . decode ( 'ascii' , 'ignore' ) except AttributeError : d = data . read ( ) . decode ( 'ascii' , 'ignore' ) return str ( d ) except ( URLError , socket . timeout , socket . error ) as e : log . debug ( 'HTTP query socket error: {0}' . format ( e ) ) if retry_count > 0 : log . debug ( 'HTTP query retrying (count: {0})' . format ( str ( retry_count ) ) ) return self . get_http_raw ( url = url , retry_count = retry_count - 1 , headers = headers , request_type = request_type , form_data = form_data ) else : raise HTTPLookupError ( 'HTTP lookup failed for {0}.' . format ( url ) ) except HTTPLookupError as e : raise e except Exception : raise HTTPLookupError ( 'HTTP lookup failed for {0}.' . format ( url ) )
The function for retrieving a raw HTML result via HTTP.

        Args:
            url (:obj:`str`): The URL to retrieve (required).
            retry_count (:obj:`int`): The number of times to retry in case
                socket errors, timeouts, connection resets, etc. are
                encountered. Defaults to 3.
            headers (:obj:`dict`): The HTTP headers. The Accept header
                defaults to 'text/html'.
            request_type (:obj:`str`): Request type 'GET' or 'POST'. Defaults
                to 'GET'.
            form_data (:obj:`dict`): Optional form POST data.

        Returns:
            str: The raw data.

        Raises:
            HTTPLookupError: The HTTP lookup failed.