我对python相当陌生,正在尝试编写一个脚本来登录位于http://ryushare.com/login.python的页面。在
我尝试了很多次,但都没能登录,我不知道为什么。 登录到页面后,我希望得到http://ryushare.com/file-manager.python的返回
下面是我试图通过阅读其他人的示例来尝试的代码。在
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()
我检查了登录页面的源代码,上面说用户名和密码值是“login and password”,所以我修改了它。 我已经尝试了一些其他的例子,可以在这里找到像谷歌新闻feed,它也无法登录:(
在页面源代码中,我们有以下HTML:
^{1}$你应该打开“动作”页面,例如
^{pr2}$http://www.w3schools.com/html/html_forms.asp:
编辑:其他表单数据
从评论中可以看出,在应用了这个修复程序之后,OP仍然有问题。答案是,通常有隐藏的表单标记,包括提交按钮的。在您的请求中包括这些标签的数据以及您的用户名和密码。在
相关问题 更多 >
编程相关推荐