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
- import re
- from mechanize import Browser
- username = "yourusername"
- password = "yourpassword"
- browser = Browser()
- url = "http://www.deviantrealms.com/index.php?act=Login&CODE=00"
- browser.open(url)
- browser.select_form('LOGIN')
- browser['UserName'] = username
- browser['PassWord'] = password
- response = browser.submit()
- response = browser.follow_link(url_regex=r"\s*Top200-L2.php")
- browser.back()
- response = browser.follow_link(url_regex=r"\s*Top100-L2.php")
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