Open the URL with urllib.request.
544163
def open(self):
        """"""
        url = self.url
        try:
            request = urllib.request.Request(url)
            handle = urllib.request.build_opener()
        except IOError:
            return None
        return (request, handle)
1093324
def download_url(url):
    ''''''
    if sys.version_info.major < 3:
        from urllib2 import urlopen as url_open
        from urllib2 import URLError as url_error
    else:
        from urllib.request import urlopen as url_open
        from urllib.error import URLError as url_error
    try:
        resp = url_open(url)
        headers = resp.info()
    except url_error as e:
        print('Error downloading %s' % url)
        return None
    return resp.read()
104721
def from_url(cls, url, **kwargs):
        """"""
        url = urllib3.util.parse_url(url)
        if url.host:
            kwargs.setdefault('host', url.host)

        if url.port:
            kwargs.setdefault('port', url.port)

        if url.scheme == 'https':
            kwargs.setdefault('connection_class', urllib3.HTTPSConnectionPool)

        return cls(**kwargs)
205456
def http_get(url, filename=None):
    """"""
    try:
        ret = requests.get(url)
    except requests.exceptions.SSLError as error:
        _LOGGER.error(error)
        return False

    if ret.status_code != 200:
        return False

    if filename is None:
        return ret.content

    with open(filename, 'wb') as data:
        data.write(ret.content)
    return True
43403
def url(self, var, default=NOTSET, force=True):
        """"""
        return self._get(var, default=default, cast=urlparse.urlparse,
                         force=force)
97447
def __open(self, url, headers=None, data=None, baseurl=""):
        """"""
        headers = headers or {}
        if not baseurl:
            baseurl = self.baseurl
        req = Request("%s%s" % (baseurl, url), headers=headers)
        _LOGGER.debug(url)

        try:
            req.data = urlencode(data).encode('utf-8')
        except TypeError:
            pass
        opener = build_opener()

        try:
            resp = opener.open(req)
            charset = resp.info().get('charset', 'utf-8')
            data = json.loads(resp.read().decode(charset))
            opener.close()
            _LOGGER.debug(json.dumps(data))
            return data
        except HTTPError as exception_:
            if exception_.code == 408:
                _LOGGER.debug("%s", exception_)
                return False
            raise TeslaException(exception_.code)
334730
private static HttpURLConnection open(URL url) throws IOException {
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setReadTimeout(TIMEOUT);
        c.setConnectTimeout(TIMEOUT);
        return c;
    }
1332268
def open(self, url, method='get', **kwargs):
        
        response = self.session.request(method, url, **self._build_send_args(**kwargs))
        self._update_state(response)
280214
def _request(self, url, request_type='GET', **params):
        """"""
        try:
            _LOGGER.debug('Request %s %s', url, params)
            response = self.request(
                request_type, url, timeout=TIMEOUT.seconds, **params)
            response.raise_for_status()
            _LOGGER.debug('Response %s %s %.200s', response.status_code,
                          response.headers['content-type'], response.json())
            response = response.json()
            if 'error' in response:
                raise OSError(response['error'])
            return response
        except OSError as error:
            _LOGGER.warning('Failed request: %s', error)
1022289
def open_url(self, url):
        
        try:
            c = pycurl.Curl()
            c.setopt(pycurl.FAILONERROR, True)
            c.setopt(pycurl.URL, "%s/api/v0/%s" % (self.url, url))
            c.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % self.userAgent,
                                         "apiToken: %s" % self.apiToken])
            b = StringIO.StringIO()
            c.setopt(pycurl.WRITEFUNCTION, b.write)
            c.setopt(pycurl.FOLLOWLOCATION, 1)
            c.setopt(pycurl.MAXREDIRS, 5)
            # Persoonlijkrooster only supports SSLv3, not the default SSLv23.
            c.setopt(pycurl.SSLVERSION, pycurl.SSLVERSION_SSLv3) 
            # Verify authenticity of peer's certificate. (0 will not check it)
            c.setopt(pycurl.SSL_VERIFYPEER, 1)
            # Verify that domain in URL matches to the Common Name Field or
            # a Subject Alternate Name field in the certificate.
            # (0 will not check it; 1 is an invalid value)
            c.setopt(pycurl.SSL_VERIFYHOST, 2) 
            c.perform()
            return b.getvalue()
        except pycurl.error, e:
            raise MyTimetableError(e)
934072
static void openURL(String url) {
    try {
      openURL(new URL(url));
    } catch (MalformedURLException ex) {
      Tools.showError(ex);
    }
  }
388257
def open(url):
    
    if sys.platform == 'win32':
        os.startfile(url)
    elif sys.platform == 'darwin':
        subprocess.Popen(['open', url])
    else:
        try:
            subprocess.Popen(['xdg-open', url])
        except OSError:
            import webbrowser
            webbrowser.open(url)
124431
def _get_url(url):
    """"""
    try:
        data = HTTP_SESSION.get(url, stream=True)
        data.raise_for_status()
    except requests.exceptions.RequestException as exc:
        raise FetcherException(exc)

    return data
522129
def open(self, url):
        
        protocol, location = self.split(url)
        if protocol == self.protocol:
            return self.find(location)
        else:
            return None
966392
def open(self, target_uri, **kwargs):
        
        target = urlsplit(target_uri, scheme=self.default_opener)

        opener = self.get_opener(target.scheme)
        query = opener.conform_query(target.query)

        target = opener.get_target(
            target.scheme,
            target.path,
            target.fragment,
            target.username,
            target.password,
            target.hostname,
            target.port,
            query,
            **kwargs
        )
        target.opener_path = target_uri

        return target
872898
def open_file(self, url):
        """"""
        if not isinstance(url, str):
            raise URLError('file error: proxy support for file protocol currently not implemented')
        if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
            raise ValueError("file:// scheme is supported only on localhost")
        else:
            return self.open_local_file(url)
956687
def get(url: str, *args, **kwargs) -> tuple:
    """"""
    return RequestsHelper.request(url, "get", *args, **kwargs)