Fetch document located at ``url`` and save to to ``location``.
346109
def download(self, url, location, **kwargs):
        

        doc = self.go(url, **kwargs)
        with open(location, 'wb') as out:
            out.write(doc.body)
        return len(doc.body)
81328
def exportSite(self, location):
        
        params = {
            "location" : location,
            "f" : "json"
        }
        url = self._url + "/exportSite"
        return self._post(url=url, param_dict=params)
811995
def download_url(url):
    ''''''
    import urllib2
    try:
        resp = urllib2.urlopen(url)
        headers = resp.info()
    except urllib2.URLError as e:
        print('Error downloading %s' % url)
        return None
    return resp.read()
811129
def find(self, location):
        
        try:
            content = self.store[location]
            return StringIO(content)
        except:
            reason = 'location "%s" not in document store' % location
            raise Exception, reason
826225
def get(self, *args, **kwargs):
        """"""
        location = args[0]
        params = self._get_keywords(location, kwargs)
        url = self._create_path(*args)
        request = requests.get(url, params=params)
        content = request.content
        self._request = request
        return self._output(content)
524294
def fetch(url, fullpath):
    '''
    
    '''
    logger.debug("Fetching %s from %s" % (fullpath, url))

    try:
        tmpfile, headers = urlretrieve(url)
        if os.path.exists(fullpath):
            os.remove(fullpath)
        shutil.move(tmpfile, fullpath)
    except Exception as e:
        logger.error("Error during fetching: " + str(e))
        raise
816805
def fetchText(cls, url, data, textSearch, optional):
        """"""
        if textSearch:
            match = textSearch.search(data[0])
            if match:
                text = match.group(1)
                out.debug(u'matched text %r with pattern %s' % (text, textSearch.pattern))
                return unescape(text).strip()
            if optional:
                return None
            else:
                raise ValueError("Pattern %s not found at URL %s." % (textSearch.pattern, url))
        else:
            return None
1168409
def get_by_location(cls, location, include_deactivated=False):
        """"""
        if include_deactivated:
            view = views.service_location
        else:
            view = views.active_service_location

        result = yield view.first(key=location, include_docs=True)
        parent = cls.parent_resource(**result['doc'])

        raise Return(cls(parent=parent, **result['value']))
692857
def downloadTo(self, href, localpath):
        
        for iTry in range(TRYINGS):
            logger.info(u("downloadTo(%s): %s %s") % (iTry, href, localpath))
            try:
                href = remote(href)
                localpath = _(localpath)

                conn = self.getConnection()
                conn.request("GET", _encode_utf8(href), "", self.getHeaders())
                response = conn.getresponse()
                checkResponse(response)
                f = None
                try:
                    while True:
                        data = _decode_utf8(response.read(1024))
                        if not data:
                            break
                        if data == u('resource not found'):
                            return False
                        if not f:
                            f = open(localpath, "w")
                        f.write(data)
                finally:
                    if f:
                        f.close()
                return True
            except ConnectionException:
                raise
            except Exception:
                e = sys.exc_info()[1]
                logger.exception(e)
198016
def fetch(self, url):
        
        url = self._get_url(url)
        so, se = self.run_git_command('ls-remote -h %s' % url)
        refs = []
        for line in (x for x in so.splitlines()):
            sha, ref = line.split('\t')
            refs.append(ref)
        refs = ' '.join(('+%s:%s' % (r, r) for r in refs))
        cmd = '''fetch %s -- %s''' % (url, refs)
        self.run_git_command(cmd)
522129
def open(self, url):
        
        protocol, location = self.split(url)
        if protocol == self.protocol:
            return self.find(location)
        else:
            return None
409566
def download(self, url, save_path, header={}, redownload=False):
        
        if save_path is None:
            logger.error("save_path cannot be None")
            return None

        # Get headers of current web driver
        header = self.get_headers()
        if len(header) > 0:
            # Add more headers if needed
            header.update(header)

        logger.debug("Download {url} to {save_path}".format(url=url, save_path=save_path))

        save_location = cutil.norm_path(save_path)
        if redownload is False:
            # See if we already have the file
            if os.path.isfile(save_location):
                logger.debug("File {save_location} already exists".format(save_location=save_location))
                return save_location

        # Create the dir path on disk
        cutil.create_path(save_location)

        if url.startswith('//'):
            url = "http:" + url
        try:
            with urllib.request.urlopen(urllib.request.Request(url, headers=header)) as response,\
            open(save_location, 'wb') as out_file:
                data = response.read()
                out_file.write(data)

        except urllib.error.HTTPError as e:
            save_location = None
            # We do not need to show the user 404 errors
            if e.code != 404:
                logger.exception("Download Http Error {url}".format(url=url))

        except Exception:
            save_location = None
            logger.exception("Download Error: {url}".format(url=url))

        return save_location
856088
def wget(url):
    
    import urllib.parse
    request = urllib.request.urlopen(url)
    filestring = request.read()
    return filestring
419175
def loadFromURL(self, url):
        """"""
        if isfile(url) is True:
            file = open(url, 'r')
        else:
            file = urlopen(url)

        try:     
            result = self.loadDocument(file)
        except Exception, ex:
            file.close()
            raise ParseError(('Failed to load document %s' %url,) + ex.args)
        else:
            file.close()
        return result
639413
def _download_from_url(self, url):
        
        ext = get_file_extension(url)
        if "?" in url:
            ext = get_file_extension(os.path.splitext(url.split("?")[0]))
        filepath = "/tmp/%s.%s" % (uuid.uuid4().hex, ext)
        request.urlretrieve(url, filepath)
        return filepath
1121731
def go_to(self, url_or_text):
        """"""
        if is_text_string(url_or_text):
            url = QUrl(url_or_text)
        else:
            url = url_or_text
        self.webview.load(url)
487785
def fetch_and_parse(url, bodyLines):
    """"""

    pageHtml = fetch_page(url)
    return parse(url, pageHtml, bodyLines)