- 论坛徽章:
- 0
|
本帖最后由 zhy19870722 于 2013-03-12 16:30 编辑
使用post方式模拟登录,没有登录成功- def postMethod():
-
- postUrl = "http://172.16.1.201/cdp/login/login!toLogin.action"
- param = {
- "j_username":"admin",
- "j_password":"123456"
- }
-
- opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor())
- urllib.request.install_opener(opener)
-
- user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
- headers = {
- "User-Agent" : user_agent
- }
-
- data = urllib.parse.urlencode(param).encode(encoding="utf-8")
- req = urllib.request.Request(postUrl,data,headers)
-
- conn = opener.open(req)
- print(conn.geturl())
-
- if __name__ == "__main__":
- postMethod()
复制代码 已搞定,传入的url地址不正确,多谢热心的朋友 |
|