1
我已經閱讀了關於此的其他文章,但我認爲我的情況有點獨特。我想使用Python來閱讀我的成績離開學校的家庭接入中心的網站,但我覺得有東西在他們有它編程的方式奇特,這裏是我使用的代碼:使用urllib驗證網頁的Python
import urllib
def WebLogin(password):
params = urllib.urlencode(
{'txtLogin': username,
'txtPassword': password })
f = urllib.urlopen("http://home.tamdistrict.org/homeaccess/Student/Assignments.aspx", params)
if "The following errors occurred while attempting to log in:" in f.read():
print "Login failed."
print f.read()
else:
print "Correct!"
print f.read()
無論我輸入用戶名和密碼,它總是打印「正確」。每個f.read()只返回一個空行。我真的被困在這裏,謝謝你的幫助!