我将在 gmail 上对此进行测试,因为它是一个很多人拥有并且知道如何使用的简单平台。如果 a) 我的代码错误并且 b) 网络表单所需的参数输入是什么,请赐教。
我的代码目前是:
data = {'Email':"Emailtypedhere",'Passwd':"Passwordtypedhere"}
#note that I use 'Email' and 'Passwd' based on the name= of the username/password form fields.
#if I should be using it based on the id= please advise. Thanks!
url = "https://accounts.google.com/ServiceLoginAuth"
data_in_string = urllib.parse.urlencode(data)
data_in_bytes = data_in_string.encode('utf-8')
urllib.request.urlopen(url,data_in_bytes)
从那我会假设我现在已经登录到 gmail。那是对的吗?我从表单中的action
类型、Passwd
标签表单密码和Email
电子邮件标签表单中获取了 URL。
这是来自 Gmail 的代码,专门用于表单。如果我缺少任何参数或者我的代码是否有效,请告诉我。谢谢!
<form novalidate="" id="gaia_loginform" action="https://accounts.google.com/ServiceLoginAuth" method="post">
<input type="hidden" name="continue" id="continue" value="https://mail.google.com/mail/">
<input type="hidden" name="service" id="service" value="mail">
<input type="hidden" name="rm" id="rm" value="false">
<input type="hidden" name="dsh" id="dsh" value="-6956126811101026847">
<input type="hidden" name="ltmpl" id="ltmpl" value="default">
<input type="hidden" name="hl" id="hl" value="en">
<input type="hidden" name="scc" id="scc" value="1">
<input type="hidden" name="ss" id="ss" value="1">
<input type="hidden" name="GALX" value="q83s3oZvHfE">
<input type="hidden" id="pstMsg" name="pstMsg" value="1">
<input type="hidden" id="dnConn" name="dnConn" value="">
<input type="hidden" id="checkConnection" name="checkConnection" value="youtube:377:1">
<input type="hidden" id="checkedDomains" name="checkedDomains" value="youtube">
<input type="hidden" name="timeStmp" id="timeStmp" value="">
<input type="hidden" name="secTok" id="secTok" value="">
<div class="email-div">
<label for="Email"><strong class="email-label">Username</strong></label>
<input type="email" spellcheck="false" name="Email" id="Email" value="">
</div>
<div class="passwd-div">
<label for="Passwd"><strong class="passwd-label">Password</strong></label>
<input type="password" name="Passwd" id="Passwd">
</div>
<input type="submit" class="g-button g-button-submit" name="signIn" id="signIn" value="Sign in">
<label class="remember" onclick="">
<input type="checkbox" name="PersistentCookie" id="PersistentCookie" value="yes">
<strong class="remember-label">
Stay signed in
</strong>
</label>
<input type="hidden" name="rmShown" value="1">
</form>