這是腳本>>Python:網絡登錄腳本,有什麼問題?
import ClientForm
import urllib2
request = urllib2.Request("http://ritaj.birzeit.edu")
response = urllib2.urlopen(request)
forms = ClientForm.ParseResponse(response, backwards_compat=False)
response.close()
form = forms[0]
print form
sooform = str(raw_input("Form Name: "))
username = str(raw_input("Username: "))
password = str(raw_input("Password: "))
form[sooform] = [username, password]
request2 = form.click()
try:
response2 = urllib2.urlopen(request2)
except urllib2.HTTPError, response2:
pass
print response2.geturl()
print response2.info() # headers
print response2.read() # body
response2.close()
時啓動腳本,,我得到這個
Traceback (most recent call last):
File "C:/Python26/ritaj2.py", line 9, in <module>
form = forms[0]
IndexError: list index out of range
什麼問題,第,,我在Windows上運行,蟒蛇2.6.4
更新:
我想要一個腳本,登錄此網站,並打印迴應:)
你自己調查問題多久了? – 2010-03-07 13:50:57
我試圖讓這個腳本大約兩天前,並沒有得到任何東西,每次我有一個代碼,它顯示了一個錯誤,,所以如果你可以幫助我使這個網站的登錄腳本,我會感激: ) – 2010-03-07 14:04:52