0

We have Java application running on tomcat server and i wrote a simple script to login but i won't allow me to login it is just hanging on br.open step.

#!/usr/bin/python
import mechanize
br=mechanize.Browser()
br.open('https://www.example.com')
br.select_form(nr=0)
br['user[login]']= user1
br['user[password]']= Pass1
br.submit()
br.retrieve('https://www.example.com/','page1.html')

When i am running it interactively on python shell its hanging on br.open

>>> br.open('https://www.example.com/')

hanging here.....

Does mechanize work with j_security_check? or java base application?

Satish
  • 16,544
  • 29
  • 93
  • 149

1 Answers1

0

I'm not familiar with mechanize, generally speaking, urllib2 is where you go to do HTML in Python. Is it possible to try this with http rather than https?

The Java app also needs to serve HTML, in standard format. mechanize basically just pulls down the HTML and lets you do stuff with it, note that it will not run the Javascript, so if that login screen is a Javascript popup, it's not going to work, I believe it only does things in standard GET POST format.

Seth Curry
  • 151
  • 4
  • http redirected to httpd, also i have checked source info and its html. I don't know why its not working.. – Satish May 10 '13 at 16:03
  • I added a comment after that, but it doesn't seem to have saved it. Anyhow, [here's](http://stackoverflow.com/questions/11276461/sending-post-parameters-with-python-using-mechanize) a link to a similar post on SO that might help. It also looks like you're trying to pass an array through POST, which I'm fairly certain you can't do directly, unless this is some special feature of the libraries. – Seth Curry May 10 '13 at 19:38