解释下面这段python代码
时间:2010-10-19
来源:互联网
最好详细点
Python code
Python code
class loginInfo(QtCore.QThread): def __init__(self, conn, parent): QtCore.QThread.__init__(self, parent) self.conn = conn self.username, self.password = self.conn.getUsernameAndPassword() def run(self): mutex2.lock() self.status = self.getConnection() mutex2.unlock() def getConnection(self): md5passwd = hashlib.md5(self.password).hexdigest() self.passwd = md5passwd[8:24] self.conn.setPasswd(self.passwd) self.conn = httplib.HTTPConnection("www.cc98.org") self.conn.putrequest("GET", "/index.asp") self.conn.endheaders() res = self.conn.getresponse() res.read() self.cookie = res.getheader("set-cookie") sessionlist = re.findall(r"ASPSESSION.*(?=; path=/)", self.cookie) session = sessionlist[0] self.cookie = "BoardList=BoardID=Show; " + session data = urllib.urlencode({"a":"i", "u":self.username, "p":md5passwd, "userhidden":"2"}) Content_Length = data.__len__() self.conn.putrequest("GET", "/sign.asp") self.conn.putheader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") self.conn.putheader("Cookie", self.cookie) self.conn.putheader("Content-Length", str(Content_Length)) self.conn.endheaders() self.conn.send(data) res = self.conn.getresponse() if res.read() != "9898": return False userinfo = re.findall(r"aspsky.*?(?=;\s)", res.getheader("set-cookie")) self.cookie = "BoardList=BoardID=Show; upNum=0; " + session + "; " + userinfo[0] return True def getStatus(self): return self.status def getCookie(self): return self.cookie
作者: zhbzljxw 发布时间: 2010-10-19
这问题就好像“教我Python,最好从头教”一样。需要别人帮助的时候,要让别人相信你自己努力过了。否则完全是在浪费别人的时间。
作者: iambic 发布时间: 2010-10-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28