0
我試圖使用在Kent's Korner中讀取的代碼進行基於表單的身份驗證。至少我被告知我正在嘗試閱讀的網站是基於表單的身份驗證。使用Python進行基於表單的身份驗證
但我似乎無法通過登錄頁面。我正在使用的代碼是
Import urllib, urllib2, cookielib, string
# configure an opener that will handle cookies
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
# use the opener to POST to the login form and the protected page
params = urllib.urlencode(dict(username='user', password='stuff'))
f = opener.open('http://www.hammernutrition.com/forums/memberlist.php?mode=viewprofile&u=1323', params)
data = f.read()
f.close()
f = opener.open('http://www.hammernutrition.com/forums/memberlist.php?mode=viewprofile&u=1323')
data = f.read()
f.close()
您可能必須模擬提交按鈕單擊。 – Marco 2011-01-31 04:24:01