Skip to content

Instantly share code, notes, and snippets.

@thanos
Created July 12, 2012 17:06
Show Gist options
  • Select an option

  • Save thanos/3099353 to your computer and use it in GitHub Desktop.

Select an option

Save thanos/3099353 to your computer and use it in GitHub Desktop.
A quick version of urlopen but nearly always works
import httplib2
def url_fetch(url, user=None, password=None, method="GET", body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
"""
A quick version of urlopen but nealry always works
"""
h = httplib2.Http(".cache")
if user:
h.add_credentials(user,password)
return h.request(url, method=method, body=body, headers=headers, redirections=redirections, connection_type=connection_type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment