Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(4)  |  Derive(0)  |  Import(4)
Asynchronously fetch a URL.

It takes these arguments:

    ``url``: the url to fetch

    ``content_callback``: A function that is called with the URL's content

    ``data`` (optional): Additional POST data
(more...)

        def fetch_url(url, content_callback, data={}, auth=None):
    """
    Asynchronously fetch a URL.

    It takes these arguments:

        ``url``: the url to fetch

        ``content_callback``: A function that is called with the URL's content

        ``data`` (optional): Additional POST data

        ``auth`` (optional): A tuple in the format (username, password) that's
                             used for http authentication

    """
    req = Request(url)

    if auth:
        base64string = base64.encodestring('%s:%s' % auth)[:-1]
        req.add_header("Authorization", "Basic %s" % base64string)

    if data:
        urlargs = (req, urlencode(data))
    else:
        urlargs = (req,)

    def _fetcher():
        try:
            f = urlopen(*urlargs)
            content = f.read()
            url = f.url
        except Exception, e:
            content = str(e)
            url = None
        return url, content

    task = AsyncTask(_fetcher, content_callback)
    task.start()
        


src/p/i/pida-0.6.2/pida-plugins/trac/trac.py   pida(Download)
from pida.ui.htmltextview import HtmlTextView
 
from pida.utils.web import fetch_url
from pida.utils.feedparser import parse
 
def trac_report(base_address, report_id, callback, auth):
    action_fragment = 'report/%s?format=rss' % report_id
    action_url = urljoin(base_address, action_fragment)
    fetch_url(action_url, callback, auth=auth)
 

src/p/i/pida-0.6.2/pida-plugins/pastebin/pastebin.py   pida(Download)
from pida.ui.views import PidaView
 
from pida.utils.web import fetch_url
 
# locale
    def post(self, *args):
        self.args = args
        fetch_url(self.PASTE_URL, self.on_posted, self.create_data_dict(*args))
 
    def on_posted(self, url, content):

src/p/i/pida-0.6.2/pida/services/plugins/plugins.py   pida(Download)
from pida.core.environment import plugins_dir
 
from pida.utils.web import fetch_url
 
from . import metadata
            if content:
                self.install(item, content)
        fetch_url(item.url, download_complete)
 
    def install(self, item, content):

src/p/i/pida-0.6.2/pida-plugins/koders/koders.py   pida(Download)
 
from pygtkhelpers.gthreads import GeneratorTask, gcall
from pida.utils.web import fetch_url
from pida.utils.feedparser import parse
 
            url = url + '&li=%s' % licence
        self._view.start_pulse()
        fetch_url(url, self.search_callback)
 
    def search_callback(self, url, data):