帮我看看这段代码是什么意思.

帮我看看这段代码是什么意思.

params = urllib.urlencode({'connectname': '',
'connecttype': -1,
'consumeright': 0,
'separatecard': 0,
'localip': '220.189.67.3',
'IsIndex': 0,
'username': '2004090600010',
'password': '111111',
'cookiedate': 0})

print params

conn.request('POST', '/secu/webLogin.jsp', params, headers)
response = conn.getresponse()
s = response.read()
start = string.find(s, HOSTNAME)
end = string.find(s, "')", start)
s = s[start:end]
URL = s
cookie2 = response.getheader("Set-Cookie")
print URL
print "cookie2----->>>",cookie2

#第四步, 获取注册信息,这是keep-alive的关键步骤,这里的请求地址是上个response返回的.
#four get regist parameters
conn = httplib.HTTPConnection(HOSTNAME)

headers = {'Accept': 'text/html', 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie
}
start = string.find(URL, "/")
end = string.find(URL, "?", start)
URL2 = URL[start:end]
params = URL[end+1:]
print "========deal response========"
print URL2, headers
print "=====params====", params

conn.request('GET', URL2, params, headers)
response = conn.getresponse()
s = response.read()
print s
start = string.find(s, "PortalClient.loginsuc(")
end = string.find(s, ");", start)
print s[start:end]
print "kl-session=",cookie
print "get-session=",response.getheader("Set-Cookie")

#loginstr = s[start:end]

loginstr = s[start + 23:end]
loginstr = string.replace(loginstr, "\r", "")
loginstr = string.replace(loginstr, "\n", "")
loginstr = string.replace(loginstr, " ", "")
loginstr = string.replace(loginstr, "'", "")
print loginstr

L = string.split(loginstr, ',')
print L

user = L[0]
isnno = '1204'
loginkey = L[6]
ip = L[7]



这个是代码中的一小段,我困惑的地方是loginstr = s[start + 23:end]后面的代码,为什么L[6]抓出来的就是loginkey啊?
疑惑中......
后面的代码是什么意思?
len("PortalClient.loginsuc(") = 22


QUOTE:
原帖由 asnama 于 2007-8-4 23:41 发表
len("ortalClient.loginsuc(" = 22

哦,3Q,原来加23是截取新字符串啊 ,我钻牛角尖了


那关于loninkey的那个问题何解呢?