关于python 3 使用urllib 通过post提交表单,但表单并没有提交出去
importurllib.requestasrequestimporturllib.parseasparseurl='http://localhost:8080/wl/u...
import urllib.request as request
import urllib.parse as parse
url='http://localhost:8080/wl/user/login.jsp'
data=parse.urlencode({"username":"test","password":"12345"})
data=data.encode("utf8")
req=request.urlopen(url,data)
s=req.read()
s=s.decode("utf8")
with open("temphtml.html","w") as f:
print(s,file=f)
pass
没有得到我想要的登录成功的页面,我想请教下我错在哪里?应该如何做?
下附页面代码
<form name="form1" action="login!login.do" method="post">
<table width="320" height="260" border="0" cellpadding="0" cellspacing="0" background="/wl/image/login.gif">
<tr>
<td height="181"> </td>
</tr>
<tr>
<td height="38" align="center"> 用户名:
<input type="text" name="username" id="username" size="10" maxlength="20">
密码:
<input type="password" name="password" id="password" size="12" maxlength="20"></td>
</tr>
<tr>
<td height="33" align="center" valign="top">
<input type="submit" value="登录" name="login" onClick="return check()">
<input type="button" value="返回主页" name="back" onClick="goback()">
<a href="/wl/user/register.jsp">注册</a> <a href="/user/found.jsp">忘密</a>
</td>
</tr>
</table>
</form> 展开
import urllib.parse as parse
url='http://localhost:8080/wl/user/login.jsp'
data=parse.urlencode({"username":"test","password":"12345"})
data=data.encode("utf8")
req=request.urlopen(url,data)
s=req.read()
s=s.decode("utf8")
with open("temphtml.html","w") as f:
print(s,file=f)
pass
没有得到我想要的登录成功的页面,我想请教下我错在哪里?应该如何做?
下附页面代码
<form name="form1" action="login!login.do" method="post">
<table width="320" height="260" border="0" cellpadding="0" cellspacing="0" background="/wl/image/login.gif">
<tr>
<td height="181"> </td>
</tr>
<tr>
<td height="38" align="center"> 用户名:
<input type="text" name="username" id="username" size="10" maxlength="20">
密码:
<input type="password" name="password" id="password" size="12" maxlength="20"></td>
</tr>
<tr>
<td height="33" align="center" valign="top">
<input type="submit" value="登录" name="login" onClick="return check()">
<input type="button" value="返回主页" name="back" onClick="goback()">
<a href="/wl/user/register.jsp">注册</a> <a href="/user/found.jsp">忘密</a>
</td>
</tr>
</table>
</form> 展开
1个回答
展开全部
<form name="form1" action="login!login.do" method="post">
然后你提交的地址是url='http://localhost:8080/wl/user/login.jsp'
所以……
然后你提交的地址是url='http://localhost:8080/wl/user/login.jsp'
所以……
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询