using urllib, urllib2 ,mechanize to access password protected site

comeshopcheap moishyyehuda at
Thu Jun 28 15:42:01 CEST 2007


I am using this script to access (I need to download some
files) but I keep on being sent back to the login page not the user
home page. Any help. I think I may need to use a post method and
opener is using a get method


import mechanize
cookies = mechanize.CookieJar()
# build_opener() adds standard handlers (such as HTTPHandler and
# HTTPCookieProcessor) by default.  The cookie processor we supply
# will replace the default one.
opener =
opener.addheaders = [("User-agent", "Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv: Gecko/20070515 Firefox/"), ]
#r ="")  # GET
r ="", data)  # POST

More information about the Python-list mailing list