472,328 Members | 976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Submitting forms over HTTPS with mechanize

Rex
Hello,

I am working on an academic research project where I need to log in to
a website (www.lexis.com) over HTTPS and execute a bunch of queries to
gather a data set. I just discovered the mechanize module, which seems
great because it's a high-level tool. However, I can't find any decent
documentation for mechanize apart from the docstrings, which are
pretty thin. So I just followed some other examples I found online, to
produce the following:

baseurl = 'http://www.lexis.com/'
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-Agent', 'Firefox')]
br.open(baseurl)
br.select_form(name="formauth")
br["USER_ID"]="my_user_id"
br["PASSWORD"]="my_password"
result = br.submit()

This code hangs at br.submit(), and I can't tell what I'm doing wrong.
Typically I would inspect the HTTP data with an HTTP debugging proxy
(Fiddler), but I guess since this is HTTPS I can't do that. Any
glaring errors in my code?

By the way, does anyone have suggestions for Python modules that I
should use instead of mechanize (and that are sufficiently easy)? If
mechanize fails, I might try modifying some similar Perl code a friend
sent me that logs into lexis.com.

Thanks so much,

Rex
Sep 4 '08 #1
2 4827
Rex wrote:
Hello,

I am working on an academic research project where I need to log in to
a website (www.lexis.com) over HTTPS and execute a bunch of queries to
gather a data set. I just discovered the mechanize module, which seems
great because it's a high-level tool. However, I can't find any decent
documentation for mechanize apart from the docstrings, which are
pretty thin. So I just followed some other examples I found online, to
produce the following:

baseurl = 'http://www.lexis.com/'
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-Agent', 'Firefox')]
br.open(baseurl)
br.select_form(name="formauth")
br["USER_ID"]="my_user_id"
br["PASSWORD"]="my_password"
result = br.submit()

This code hangs at br.submit(), and I can't tell what I'm doing wrong.
Typically I would inspect the HTTP data with an HTTP debugging proxy
(Fiddler), but I guess since this is HTTPS I can't do that. Any
glaring errors in my code?

By the way, does anyone have suggestions for Python modules that I
should use instead of mechanize (and that are sufficiently easy)? If
mechanize fails, I might try modifying some similar Perl code a friend
sent me that logs into lexis.com.

Thanks so much,

Rex
I've used mechanize quite successfully but others have suggested Twill
http://twill.idyll.org/. It seems to be at least documented.

-Larry
Sep 4 '08 #2
Rex
On Sep 3, 10:17*pm, Larry Bates <larry.ba...@vitalEsafe.comwrote:
Rex wrote:
Hello,
I am working on an academic research project where I need to log in to
a website (www.lexis.com) over HTTPS and execute a bunch of queries to
gather a data set. I just discovered the mechanize module, which seems
great because it's a high-level tool. However, I can't find any decent
documentation for mechanize apart from the docstrings, which are
pretty thin. So I just followed some other examples I found online, to
produce the following:
baseurl = 'http://www.lexis.com/'
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-Agent', 'Firefox')]
br.open(baseurl)
br.select_form(name="formauth")
br["USER_ID"]="my_user_id"
br["PASSWORD"]="my_password"
result = br.submit()
This code hangs at br.submit(), and I can't tell what I'm doing wrong.
Typically I would inspect the HTTP data with an HTTP debugging proxy
(Fiddler), but I guess since this is HTTPS I can't do that. Any
glaring errors in my code?
By the way, does anyone have suggestions for Python modules that I
should use instead of mechanize (and that are sufficiently easy)? If
mechanize fails, I might try modifying some similar Perl code a friend
sent me that logs into lexis.com.
Thanks so much,
Rex

I've used mechanize quite successfully but others have suggested Twillhttp://twill.idyll.org/. *It seems to be at least documented.

-Larry
Thanks for the reply, Larry. I ran my code again and it worked; there
was probably some temporary issue with either my computer or the
server that caused it to hang.
Sep 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: rbt | last post by:
How can I make a python client script connect to a Web server and automatically populate form fields and then submit the form? For example, say I...
1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a...
2
by: Kowalski | last post by:
from mechanize import Browser br = Browser() br.open("http://www.google.com") #example for form in br.forms(): print form ...
3
by: Hari Sekhon | last post by:
Hi everyone, I want to create a test that will do a proper login test to a web site but I need some pointers. I need to login to the website...
1
by: Edward Drake | last post by:
I'm trying to interact with a web page that uses JavaScript to add fields to a form if certain things are selected in the first field. I've tried...
6
by: sureshbup | last post by:
Hi, i am new to perl... i tried this module mechanize. this is the script #!/usr/bin/perl # Include the WWW::Mechanize module use...
1
by: mithunmo | last post by:
Hello All, How do we access form using Win32::IE::Mechanize->new( ) ? I know we have a method $mech->form_name('"name") .But what if the...
0
by: Jett | last post by:
Has anybody used the mechanize library with a Yahoo site? I am trying to create a program that will download my player's stats from Yahoo's...
12
by: MimiMi | last post by:
Hi y'all! I'm new at perl, and I'm trying to automate a file fetch. I have this url (in this example called 'https://GetMyFile'), which, when I...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.