Skip to content

Instantly share code, notes, and snippets.

@blue-bird1
Created November 23, 2018 13:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blue-bird1/e96d4f212fc43bf4683566afccdbe073 to your computer and use it in GitHub Desktop.
Save blue-bird1/e96d4f212fc43bf4683566afccdbe073 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import requests
from cqhttp_helper import CQHttp
bot = CQHttp(
access_token="ac0f790e1fb74ebcaf45da77a6f9de47",
api_root="http://127.0.0.1:5700")
import pdb
def bknHash(skey, init_str=5381):
hash_str = init_str
for i in skey:
hash_str += (hash_str << 5) + ord(i)
hash_str = int(hash_str & 2147483647)
return hash_str
cookie = bot.get_cookies()['cookies']
csrftoken = bot.get_csrf_token()['token']
cookies = cookie.split(";")
cookie = {}
for _ in cookies:
key, value = _.strip().split("=")
cookie[key] = value
skey = cookie['skey']
# skey = [ _.split("=")[1] for _ in cookies if _.strip().split("=")[0]=="skey" ]
bkn = bknHash(skey)
groupid = ""
file_id = ""
uin = cookie['uin']
# /102/ and /104/ 看上去和文件大小有关 TODO
url = "http://qun.qzone.qq.com/cgi-bin/group_share_get_downurl?uin="+uin+"&pa=/102/" + \
file_id+"&groupid="+groupid+"&bussinessid=0&charset=utf-8&g_tk="+str(bkn)+"&r=888"
ret = requests.get(url, cookies=cookie)
data = json.loads(ret.text.split("(")[1].split(")")[0])['data']
downloadurl = data['url']
print(downloadurl)
@NickLiu6189
Copy link

102是永久文件,104是临时文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment