qq空间批量下载别人的qq相册

方便下载美女qq相册

当然为了方便就没做登陆那些直接用cookie操作

某些地方用到了一些js计算execjs库

# -*- coding: utf-8 -*-
import sys
import re
import requests
import execjs
# reload(sys)
# sys.setdefaultencoding( "utf-8" )

#你的cookie 要有p_skey参数 具体自己找
cookie="填自己的cookie"
uin="你自己的qq"
fuin="下的人的qq"

def getHttp(url):
    headers = {'Referer': 'https://qzs.qq.com/qzone/photo/v7/page/photo.html?init=photo.v7/module/albumList/index&navBar=1',
               'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.3.0',
               'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
               'cookie':cookie
    }
    s = requests.session()
    return s.get(url, headers=headers).content

def m():
    t = execjs.compile("function time(){return String(Math.random().toFixed(16)).slice(-9).replace(/^0/, '9')}").call(
        'time')
    gtk_t = 'function a(skey){var hash = 5381;for (var i = 0, len = skey.length;i < len;++i) {hash += (hash << 5) + skey.charCodeAt(i);}return hash & 2147483647;}'
    qq = cookie.split("p_skey=")[1].split(";")[0]
    gtk = execjs.compile(gtk_t).call('a', qq)  # .replace("p_skey=(.*?);"))
    json_qq = getHttp(
        "https://h5.qzone.qq.com/proxy/domain/photo.qzone.qq.com/fcgi-bin/fcg_list_album_v3?g_tk={0}&callback=shine0_Callback&t={1}&hostUin={2}&uin={3}&appid=4&inCharset=utf-8&outCharset=utf-8&source=qzone&plat=qzone&format=jsonp&notice=0&filter=1&handset=4&pageNumModeSort=40&pageNumModeClass=15&needUserInfo=1&idcNum=4&callbackFun=shine0&_=1516544656243".format(
            gtk, t, fuin, uin))
    if (json_qq != ""):
        json_text = json_qq.replace("shine0_Callback(", "").replace(");", "")
        a = re.findall(r'"id" : "(.*?)",', json_text)
        for x in a:
            url_q = "https://h5.qzone.qq.com/proxy/domain/photo.qzone.qq.com/fcgi-bin/cgi_list_photo?g_tk={0}&callback=shine0_Callback&t={1}&mode=0&idcNum=4&hostUin={2}&topicId={4}&noTopic=0&uin={3}&pageStart=0&pageNum=30&skipCmtCount=0&singleurl=1&batchId=&notice=0&appid=4&inCharset=utf-8&outCharset=utf-8&source=qzone&plat=qzone&outstyle=json&format=jsonp&json_esc=1&question=&answer=&callbackFun=shine0&_=1516549331973".format(
                gtk, t, fuin, uin, x)
            text = getHttp(url_q)
            b = re.findall(r'"url" : "(.*?)",', text)
            # 迭代每个相册的所有相片链接就可以下载了
            print("\r\n".join(b))
        print("操作完毕!!!")

m()

猜你喜欢

转载自my.oschina.net/KFS/blog/1649722