473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3897
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.