PyFunceble/helpers.py
def text(self):
        """
        Download the given link and return or save its :code:`requests.text`
        at the given destination.

        :rtype: mixed

        :raises:
            :code:`Exception`
                If the status code is not :code:`200`.
        """

        try:
            # We request the link.
            req = requests.get(self.link, verify=self.verification)

            if req.status_code == 200:
                # The request http status code is equal to 200.

                if self.return_data:
                    # We have to return the data.

                    # We return the link content.
                    return req.text

                # We save the link content to the parsed destination.
                File(self.destination).write(req.text, overwrite=True)

                # We return True.
                return True

            # The request http status code is not equal to 200.

            # We raise an exception saying that we were unable to download.
            raise Exception("Unable to download %s." % repr(self.link))
        except requests.exceptions.ConnectionError:
            print(Fore.RED + "No Internet connection available." + Style.RESET_ALL)
            exit(1)
def text(self):
        """
        Download the given link and return or save its :code:`requests.text`
        at the given destination.

        :rtype: mixed

        :raises:
            :code:`Exception`
                If the status code is not :code:`200`.
        """

        try:
            # We request the link.
            req = requests.get(self.link, verify=self.verification)

            if req.status_code == 200:
                # The request http status code is equal to 200.

                if self.return_data:
                    # We have to return the data.

                    # We return the link content.
                    return req.text

                # We save the link content to the parsed destination.
                File(self.destination).write(req.text, overwrite=True)

                # We return True.
                return True

            # The request http status code is not equal to 200.

            # We raise an exception saying that we were unable to download.
            raise Exception("Unable to download %s." % repr(self.link))
        except requests.exceptions.ConnectionError:
            print(Fore.RED + "No Internet connection available." + Style.RESET_ALL)
            exit(1)
def text ( self ) : try : # We request the link. req = requests . get ( self . link , verify = self . verification ) if req . status_code == 200 : # The request http status code is equal to 200. if self . return_data : # We have to return the data. # We return the link content. return req . text # We save the link content to the parsed destination. File ( self . destination ) . write ( req . text , overwrite = True ) # We return True. return True # The request http status code is not equal to 200. # We raise an exception saying that we were unable to download. raise Exception ( "Unable to download %s." % repr ( self . link ) ) except requests . exceptions . ConnectionError : print ( Fore . RED + "No Internet connection available." + Style . RESET_ALL ) exit ( 1 )
Download the given link and return or save its :code:`requests.text`
        at the given destination.

        :rtype: mixed

        :raises:
            :code:`Exception`
                If the status code is not :code:`200`.
Download the given link and return or save its : code : requests . text at the given destination .