【发布时间】:2013-10-17 08:27:29
【问题描述】:
作为项目的一部分,我试图让 python 接收 HTML 发送的表单。获取变量后,我需要 python 在控制台中打印“True”或“False”。这是我当前的表单 HTML 代码。
...
<form name = "input" action = "CheckLogin.py" method = "get">
<!-- This is the form. Here the user submits their username and password.
The words before the colon are the words that appear on the user's screen -->
Username: <input type = "text" name = "htmlUser">
<br>
Password: <input type = "password" name = "htmlPassword">
<input type = "submit" value = "Submit">
<br>
</form>
...
一旦我让他们提交了他们的用户名和密码,我想使用这些数据来检查他们是否可以登录到电子邮件服务器(在这种情况下我使用了 Google 的,Microsoft Server 2003 不能很好地运行。)这里是我这样做的 Python 3 脚本:
def login(username, password):
import poplib
try:
server = poplib.POP3_SSL('pop.gmail.com', 995)#Weird bug here. When I use the exeter server, I am informed that the SSL number is incorrect. How do I fix?
server.user(username)
server.pass_(password)
print ("True")
except:
print("False")
login (username, password)
我的问题是,如何让 python 从 HTML 网络表单中获取 username 和 password 变量?
【问题讨论】:
标签: python html python-3.x