Skip to content

Commit

Permalink
修复2012 12-29 验证
Browse files Browse the repository at this point in the history
Signed-off-by: nelson_guo <likaifuismyson@gmail.com>
  • Loading branch information
mastergyp committed Nov 28, 2012
1 parent d87578b commit 2356e47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ http://lixian.qq.com/


调用aria2下载
可实现多线程,断点续传等特性
可实现多线程,断点续传等特性

12 12 29 修复腾讯改版后无法登陆,和登陆验证referer
16 changes: 13 additions & 3 deletions xfdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def hexchar2bin(hex):
arry.append(int(hex[i:i+2],16))
return arry

def get_gtk(strs):
hash = 5381
for i in strs:
hash += (hash << 5) + ord(i)
return hash & 0x7fffffff;

class LWPCookieJar(cookiejar.LWPCookieJar):
def save(self, filename=None, ignore_discard=False, ignore_expires=False,userinfo=None):
Expand All @@ -48,7 +53,7 @@ def save(self, filename=None, ignore_discard=False, ignore_expires=False,userinf
if not os.path.exists(filename):
f=open(filename,'w')
f.close()
f = open(filename, "rw+")
f = open(filename, "r+")
try:
if userinfo:
f.seek(0)
Expand Down Expand Up @@ -109,7 +114,7 @@ def start(self):


opener = request.build_opener(request.HTTPCookieProcessor(self.cookieJar))
opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
opener.addheaders = [('User-Agent', 'Mozilla/5.0'),("Referer","http://lixian.qq.com/main.html")]
request.install_opener(opener)


Expand Down Expand Up @@ -195,8 +200,13 @@ def getfilename_url(self,url):
filename=url.split("/")[-1]
return filename.split("?")[0]
def __getlogin(self):
self.__request(url ="http://lixian.qq.com/handler/lixian/check_tc.php",data={},savecookie=True)
urlv = 'http://lixian.qq.com/handler/lixian/do_lixian_login.php'
str = self.__request(url =urlv,data={},savecookie=True)
f=open(self.__cookiepath)
fi = re.compile('skey="([^"]+)"')
skey = fi.findall("".join(f.readlines()))[0]
f.close()
str = self.__request(url =urlv,data={"g_tk":get_gtk(skey)},savecookie=True)
return str

def __getlist(self):
Expand Down

0 comments on commit 2356e47

Please # to comment.