472,950 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

basic mechanize help

I'm trying to learn the basics of the mechanize module and i'm very very new to programming.
Does anyone know of some good places to learn the very basics, say with some examples as well?

I found this off of a person's blog
Expand|Select|Wrap|Line Numbers
  1. import re
  2. from mechanize import Browser
  3.  
  4. username = "yourusername"
  5. password = "yourpassword"
  6.  
  7. browser = Browser()
  8. url = "http://www.deviantrealms.com/index.php?act=Login&CODE=00"
  9. browser.open(url)
  10. browser.select_form('LOGIN')
  11. browser['UserName'] = username
  12. browser['PassWord'] = password
  13. response = browser.submit()
  14. response = browser.follow_link(url_regex=r"\s*Top200-L2.php")
  15. browser.back()
  16. response = browser.follow_link(url_regex=r"\s*Top100-L2.php")
This looks like what i think I want to do. that is sign into a web site.

However, does the site need to be set up such that 'LOGIN' is specified just like that in the source code?

when i tried it i get this error:
>>> browser.select_form('LOGIN')
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\site-packages\mechanize\_mechanize.py", line 510, in select_form
raise FormNotFoundError("no form matching "+description)
FormNotFoundError: no form matching name 'LOGIN'

thanks
Sep 13 '07 #1
2 3883
bartonc
6,596 Expert 4TB
That's usually due to your URL. If you can browse there in your web browser and get to that form, then it should work.


The Mechanize Readme refers to some tutorials.
Sep 13 '07 #2
Silgd1
25
I'm trying to learn the basics of the mechanize module and i'm very very new to programming.
Does anyone know of some good places to learn the very basics, say with some examples as well?

I found this off of a person's blog
Expand|Select|Wrap|Line Numbers
  1. import re
  2. from mechanize import Browser
  3.  
  4. username = "yourusername"
  5. password = "yourpassword"
  6.  
  7. browser = Browser()
  8. url = "http://www.deviantrealms.com/index.php?act=Login&CODE=00"
  9. browser.open(url)
  10. browser.select_form('LOGIN')
  11. browser['UserName'] = username
  12. browser['PassWord'] = password
  13. response = browser.submit()
  14. response = browser.follow_link(url_regex=r"\s*Top200-L2.php")
  15. browser.back()
  16. response = browser.follow_link(url_regex=r"\s*Top100-L2.php")
This looks like what i think I want to do. that is sign into a web site.

However, does the site need to be set up such that 'LOGIN' is specified just like that in the source code?

when i tried it i get this error:
>>> browser.select_form('LOGIN')
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\site-packages\mechanize\_mechanize.py", line 510, in select_form
raise FormNotFoundError("no form matching "+description)
FormNotFoundError: no form matching name 'LOGIN'

thanks

[Silgd1] View the source code of the site and make sure that the name of the form is 'LOGIN'. From the error you are receiving, it look likes the name of the form is not 'LOGIN'. View the source code of the site again and double check the name of the form. You'll be looking for something like this <FORM name=fileupload action='/emkt/xml/submit' method=post
encType=multipart/form-data target="_top">...this tells you the name of the form is "fileupload". Look for something similar to this - Silgd1[/Silgd1]
Jan 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: zoewu | last post by:
Would anyone help me with this little script that I tried to get some contents from Yahoo Personals by using Perl Mechanize. It doesn't return any results, although I've feed all kinds of browser...
12
by: John | last post by:
I have to write a spyder for a webpage that uses html + javascript. I had it written using mechanize but the authors of the webpage now use a lot of javascript. Mechanize can no longer do the job....
1
by: comeshopcheap | last post by:
Hi I am using this script to access doba.com (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...
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 WWW::Mechanize;
0
by: bruce | last post by:
i'm getting the following error: mechanize._response.httperror_seek_wrapper: HTTP Error 500: i'm running python 5.1 and mechanize 0.1.7b I have no idea as to what I have to...
1
by: Neal Becker | last post by:
I'm trying to use mechanize to read for a M$ mail server. I can get past the login page OK using: import mechanize b = mechanize.Browser() b.open...
3
by: Max | last post by:
Following the tutorial at http://personalpages.tds.net/~kent37/kk/00010.html, I understand how to access HTTP basic authenticated pages or form- based authenticated pages. How would I access a page...
2
by: Rex | last post by:
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...
1
by: tedpottel | last post by:
Hi, I can read the home page using the mechanize lib. Is there a way to load in web pages using filename.html instad of servername/ filename.html. Lots of time the links just have the file...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.