I trying to login on a website and do automated clean-up jobs.
The site where I need to login is : http://site.com/Account/LogOn
I tried various codes that I found it on Stack, like Login to website using python (but Im stuck on this line
session = requests.session(config={'verbose': sys.stderr})
where my JetBeans doesnt like 'verbose' telling me that i need to do something, but doesnt explain exactly what).
I also tried this: Browser simulation - Python, but no luck with this too.
Can anyone help me? All answers will be appreciate. Thanks in advance.
PS: I started learning Python 2 weeks ago so please elaborate your answer for my "pro" level of undersanding :)
-------------------------UPDATE:-----------------------------
I manage to login, but when I'm trying to move on other page and push a button, it says Please Log in!
I use this code:
url = 'http://site.com/Account/LogOn'
values = {'UserName': 'user',
'Password': 'pass'}
data = urllib.urlencode(values)
cookies = cookielib.CookieJar()
opener = urllib2.build_opener(
urllib2.HTTPRedirectHandler(),
urllib2.HTTPHandler(debuglevel=0),
urllib2.HTTPSHandler(debuglevel=0),
urllib2.HTTPCookieProcessor(cookies))
response = opener.open(url, data)
the_page = response.read()
http_headers = response.info()
print response
After I log in I need to swith a menu value, that looks like this in HTML:
<select id="menu_uid" name="menu_uid" onchange="swapTool()" style="font-size:8pt;width:120px;">
<option value="1" selected>MyProfile</option>
...
<option value="6" >DeleteTree</option>
but I also can do it directly if I form a URL like this: http://site.com/Account/management.html?Category=6&deltreeid=6&do=Delete+Tree
So , how can I build this URL and submit it? Thanks again!