I am quite new in python and trying to write a script to login to the page at http://ryushare.com/login.python.
I have try many attempt, but it fails to login and i have no idea why.
After login to the page, I wish to get the return of http://ryushare.com/file-manager.python
Here’s the code I try to attempt by reading the example from others.
import urllib, urllib2, cookielib
username = 'myusername'
password = 'mypassword'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'login' : username, 'password' : password})
opener.open('http://www.ryushare.com/login.python', login_data)
resp = opener.open('http://ryushare.com/file-manager.python')
print resp.read()
I check the source code of the login page, it said the username and password value is “login and password” so i change it.
I have try some other example which can be found here like google news feed, It also can not able to login : (
In the page’s source, we have the following HTML:
You should be open()’ing the “action” page, e.g.
http://www.w3schools.com/html/html_forms.asp:
Edit: Other Form Data
As can be seen in the comments, the OP still had trouble after applying this fix. The answer is that there are often hidden form tags, including the for the submit button. Include these tags’ data in your request as well as your username and password.