Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Urllib密码和用户名输入_Python_Http_Urllib2_Urllib - Fatal编程技术网

Python Urllib密码和用户名输入

Python Urllib密码和用户名输入,python,http,urllib2,urllib,Python,Http,Urllib2,Urllib,我正在制作一个程序,将我的成绩作为我的背景,但我从中获取成绩信息的网站受密码保护。有没有办法使用urllib进入我的帐户并打印源代码 这是HTML <label>Username</label> <input type="text" id="fieldAccount" name="account" value="" size="39" /> <label>Password</label> <

我正在制作一个程序,将我的成绩作为我的背景,但我从中获取成绩信息的网站受密码保护。有没有办法使用urllib进入我的帐户并打印源代码

这是HTML

<label>Username</label>
          <input type="text" id="fieldAccount" name="account" value="" size="39"  />
<label>Password</label>
          <input type="password" name="pw" value="" size="39"  />

我做错了什么

你得到了什么回应?似乎你的url是错误的,我检查了页面,表单操作是/guardian/home.html。他们发布到登录的表单有很多隐藏字段,因此尝试自己发布可能不是一个好主意
import urllib2
import urllib



url = 'https://ps.rsd.edu/public/home.html'
values = {'account':'my_username', 'pw':'my_password'}
data = urllib.urlencode(values)
opener = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
req = urllib2.Request(url,data)
res = urllib2.urlopen(req).read()
print(res)