requests.HTTPSession - python examples

Here are the examples of the python api requests.HTTPSession taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 View Complete Implementation : downloader.py
Copyright MIT License
Author : abranjith
    @staticmethod
    def latest_chrome_version(use_default=True):
        #TODO: this needs to change
        #get from chromium website
        LATEST_VERSION_PATTERN = r'Latest Release:.*ChromeDriver ([\d+\.+]+)'
        plain_text = ""
        with HTTPSession() as session:
            h = session.get(CHROME_CONSTANTS.HOME_URL)
            r = HTML(h.text)
            r.render()
            plain_text = str(r.text).encode('ascii', errors='ignore').decode()
        v = find_patterns_in_str(LATEST_VERSION_PATTERN, plain_text, first=True)
        if (not v) and use_default:
            v = CHROME_CONSTANTS.DEFAULT_VERSION
        if not v:
            message = """
            Unable to pull latest available Chromedriver version. Check,
                1. Your internet connection
                2. If internet is fine, contact implementor. Perhaps requires logic change
            """
            raise OperationFailedException(message)
        return str(v).strip()