Skip to content

Instantly share code, notes, and snippets.

@scardine
Created September 25, 2012 16:47
Show Gist options
  • Save scardine/3783062 to your computer and use it in GitHub Desktop.
Save scardine/3783062 to your computer and use it in GitHub Desktop.
Exemplo de URLLib2 com cookies
import urllib2, cookielib
url = 'https://www2.itm.tur.br/th/default.aspx'
txheaders = {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
req = urllib2.Request(url, None, txheaders)
handle = urllib2.urlopen(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment