该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
如题,我自己写了一个脚本想自动登录某网页。但是没效果,请帮忙看看那边出了问题。
我写的脚本和网站源代码入下:
--------------------------------------------------------------------------------------------------------
# -*- coding:UTF-8 -*-
import urllib
import urllib.parse
import urllib.request
def login():
opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor())
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3')]
urllib.request.install_opener(opener)
#登录路径
path ='http://server/login.asp'
#用户名和密码
post_data = urllib.parse.urlencode({'userName5k5': 'root', 'password': 'root2', 'push_type': '2'})
post_data=post_data.encode(encoding='UTF8')
print (post_data)
req = urllib.request.Request(path, post_data)
print(req)
f = urllib.request.urlopen(req)
print ("login...")
print (f.geturl() )
f.close()
assert 200 == f.code
if __name__ == '__main__':
login()
--------------------------------------------------------------------------------------------------------------
function check_val(push_id)
{
if (document.form1.userName5k5.value=="")
{
alert("Please input Login User Name!");
document.form1.userName5k5.focus();
return false;
}
if (document.form1.password.value =="")
{
alert("Please input Password!");
document.form1.password.focus();
return false;
}
document.form1.push_type.value=push_id;
document.form1.submit();
}
|