954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python Mechanize won't accept cookies - Only in Linux!

I've been working at this for nearly a week and just don't understand why it isn't working. The code works great in Windows, but once I move it to Linux, it doesn't work.

I'm basically using mechanize to login automatically to a website. The website requires cookies, however, and I can't get Linux to accept cookies using the mechanize classes. Windows works great!

Here's my code...pretty basic. Of course there is more, but this is the login part.

self.b = Browser()
self.b.open(URL_LOGIN)
self.b.select_form('Form1')
self.b["USER"] = USER
self.b["PASS"] = PASSWORD
login_response = self.b.submit()
print login_response.read()


Here is what I've tried so far.

Different versions of Ubuntu (8.04 and 9.04) with different versions of Python (2.5.2 and 2.6.2)

Install mechanize from apt sources and install mechanize from website using python setup.py install

Expliciting requiring cookies with:

self.cj = CookieJar()
self.b.set_cookiejar(cj)


NOTHING WORKS! Are there any ideas why? Please?!

bond00
Newbie Poster
3 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

bump...any ideas? This is driving me nuts. I've now tried different distributions of Linux as well.

bond00
Newbie Poster
3 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You