python爬虫实战之爬取QQ音乐

前言

  • 开始
    • 爬虫的四大步骤
    • 思路
  • 全部代码
  • 最后

过去了相当的一段时间没有更新了,先证明一下自己还活着= =,就是忙着学习linux和mysql没时间发博客,现在有时间就来发一个爬虫进阶吧,爬取某Q音乐的音乐吧!!

开始

在开始的时候先声明一下某Q音乐的vip是不要想的了,因为某Q音乐的vip是要下客户端才能听,不说了某讯真会玩…

爬虫的四大步骤

1.目标url
2.发送请求
3.解析数据
4.清洗数据
5.保存数据

这几步基本每次都有强调因为觉得真的很重要,基本爬虫都是跟着这几步走的

当你了解这些之后我们就可以开始操作了!

思路

首先我们先打开我们想要爬取的主页,先分析一下 点我进去之后我们先随便找个歌手来点开一个音乐进行抓包
python爬虫实战之爬取QQ音乐_第1张图片
抓到了包之后我们来观察一下需要带什么参数
在这里插入图片描述

经过观察发现参数都是固定的,除了vkey发生了改变,最后通过查找抓包发现了vkey,说明了它不是一个加密参数
python爬虫实战之爬取QQ音乐_第2张图片
不仅找到了vkey也直接获得了m4a的链接,通过观察发现songmid应该和后面获取有联系…

接着我们继续查看此链接需要带的参数有啥
python爬虫实战之爬取QQ音乐_第3张图片
通过了观察发现2个参数是不一样的,就是data和sign这2个参数,接着使用search查找sign=的字段发现了端倪,发现里面有个带sign的值,显示了一个链接点我查看

python爬虫实战之爬取QQ音乐_第4张图片
发现是一堆js数据,最后解析使用解析工具解析,发现需要一个data的值来获得sign,那么这不是表明了这个参数的data传进去即可得到我想要的参数吗,于是开始动手测试看看

这里没下载PyExecJS的可以直接pip install PyExecJS进行下载

import execjs


def get_sign(data):
    with open('get_sign.js', 'r', encoding='utf-8') as f:
        text = f.read()
    js_data = execjs.compile(text)
    sign = js_data.call('get_sign', data)
    return sign


if __name__ == "__main__":
    #{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":"1399367235","calltype":0,"userip":""}},"req_0":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"1399367235","songmid":["001QJyJ32zybEe"],"songtype":[0],"uin":"3320795610","loginflag":1,"platform":"20"}},"comm":{"uin":3320795610,"format":"json","ct":24,"cv":0}}
    data = '{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":"1399367235","calltype":0,"userip":""}},"req_0":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"1399367235","songmid":["0013WPvt4fQH2b"],"songtype":[0],"uin":"3320795610","loginflag":1,"platform":"20"}},"comm":{"uin":3320795610,"format":"json","ct":24,"cv":0}}'
    sign = get_sign(data)
    print(len(sign))
    print(sign)



结果
python爬虫实战之爬取QQ音乐_第5张图片
sign的参数明显不符合我们看到的sign,不过细心的朋友可能观察到了,有很多相同的字符比如finedundf,结尾后面的参数有点像之前我们看到的参数的后面的一小串
于是我去掉多余相同字符使用zzaundefinedundec6ae8dd63f7322c19a65bba416a90d22的参数换上sign的值结果发现
原URL和带sign访问的链接

python爬虫实战之爬取QQ音乐_第6张图片

修改后访问的链接

python爬虫实战之爬取QQ音乐_第7张图片
ok完全一致

所以我们知道了data的数据是关键让sign发现改变的唯一参数,接下来我们看看data参数有什么不一样的改变

data: {
     "req":{
     "module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{
     "guid":"1399367235","calltype":0,"userip":""}},"req_0":{
     "module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{
     "guid":"1399367235","songmid":["0013WPvt4fQH2b"],"songtype":[0],"uin":"3320795610","loginflag":1,"platform":"20"}},"comm":{
     "uin":3320795610,"format":"json","ct":24,"cv":0}}

经过发现我们观察到了data只有一个参数"songmid"在改变,仔细想想这不就是之前在vkey上看到的参数吗…

这下真相越来越接近了…

于是继续往上去查找,于是我们点开歌手的音乐榜单进行查看点我!!

进行抓包操作
python爬虫实战之爬取QQ音乐_第8张图片
仔细观察后发现这里的mid和之前在vkey看到的songmid是一模一样的

于是我们继续查看这条链接所需参数
python爬虫实战之爬取QQ音乐_第9张图片

通过观察发现这里的data的值的singmid和其他的不一样在发生改变,其他的没变,最后仔细一看发现,这就是明星的id号

于是我们接着往下走,到初始的位置看看是否能获取明星的id号 点我!!
结果
python爬虫实战之爬取QQ音乐_第10张图片
通过抓包找到了以下全部明星的名字和id号

还是一样,查看一下带的参数是什么

python爬虫实战之爬取QQ音乐_第11张图片
通过观察发现每次下一页这个值就会发生改变比如下一页之后的sin变为80,cur变为2以此类推下去,每页80个明星,有多少页写多少,其他的没发生改变,这里就不细说了,留个小伙伴们自己来做吧!!

到这里快讲完了,大家坚持到了这里真的很不容易,楼主写博客也不容易,如果觉得讲的不错的话,不妨给个赞再走吧~

在这里插入图片描述
好了所有参数全部搞定

全部代码

import requests
import re
import execjs
import os

class QQmusic(object):
    def __init__(self):
            self.headers={
     
                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
                'Referer': 'https://y.qq.com/portal/singer_list.html',
            }
    #主函数
    def run(self):
        data='{"comm":{"ct":24,"cv":0},"singerList":{"module":"Music.SingerListServer","method":"get_singer_list","param":{"area":-100,"sex":-100,"genre":-100,"index":-100,"sin":0,"cur_page":1}}}'

        sign=self.get_sign(data)
        #注,这里的0,1是下一页的明星号如下一页是80,2,有需要可以自行修改
        #这里是解析明星的名字和id号
        url = 'https://u.y.qq.com/cgi-bin/musics.fcg?-=getUCGI20079930333012497&g_tk=1541691288&' \
              'sign={}&loginUin=3320795610&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&data=%7B%22comm%22%3A%7B%22ct%22%3A24%2C%22cv%22%3A0%7D%2C%22singerList%22%3A%7B%22module%22%3A%22Music.SingerListServer%22%2C%22method%22%3A%22get_singer_list%22%2C%22param%22%3A%7B%22area%22%3A-100%2C%22sex%22%3A-100%2C%22genre%22%3A-100%2C%22index%22%3A-100%2C%22' \
              'sin%22%3A{}%2C%22' \
              'cur_page%22%3A{}%7D%7D%7D'.format(sign, 0, 1)
        response=self.parse_url(url)
        #明星id号
        data_id_list,name_list=self.parse_data(response)
        n=0
        s=1
        for name in name_list:
            print("%d  %s  "%(n,name),end=' ')
            if n==10*s:
                print('\n')
                s=s+1
            n=n+1
        n=int(input("\n请输入明星的序列号:"))
        print("你选择了"+name_list[n])
        url_data = '{"comm":{"ct":24,"cv":0},"singerSongList":{"method":"GetSingerSongList","param":{"order":1,"singerMid":"%s","begin":0,"num":10},"module":"musichall.song_list_server"}}'%str(data_id_list[n])
        url_html = self.get_sign(url_data)
        music_html='https://u.y.qq.com/cgi-bin/musics.fcg?-=getSingerSong9337150917069357&g_tk=1541691288&sign={}&' \
                   'loginUin=3320795610&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&' \
                   'data=%7B%22comm%22%3A%7B%22ct%22%3A24%2C%22cv%22%3A0%7D%2C%22singerSongList%22%3A%7B%22method%22%3A%22GetSingerSongList%22%2C%22param%22%3A%7B%22order%22%3A1%2C%22singerMid%22%3A%22{}%22%2C%22begin%22%3A0%2C%22num%22%3A10%7D%2C%22module%22%3A%22musichall.song_list_server%22%7D%7D'.format(url_html,data_id_list[n])
        #歌手的歌名
        html_list=self.parse_url(music_html)
        music,title=self.music_list(html_list,name_list[n])
        music_data='{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":"1399367235","calltype":0,"userip":""}},"req_0"' \
                 ':{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"1399367235",' \
                 '"songmid":["%s"],"songtype":[0],"uin":"3320795610","loginflag":1,"platform":"20"}},"comm":{"uin":3320795610,"format":"json","ct":24,"cv":0}}'%(str(music))
        #获取音乐的钥匙
        url_html=self.get_sign(music_data)
        #最后钥匙的链接啦
        html='https://u.y.qq.com/cgi-bin/musics.fcg?-=getplaysongvkey37572959288093255&g_tk=1541691288&sign={}&' \
             'loginUin=3320795610&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&data=%7B%22req%22%3A%7B%22module%22%3A%22CDN.SrfCdnDispatchServer' \
             '%22%2C%22method%22%3A%22GetCdnDispatch%22%2C%22param%22%3A%7B%22guid%22%3A%221399367235%22%2C%22calltype%22%3A0%2C%22userip%22%3A%22%22%7D%7D%2C%22req_0%22%3A%7B%22module%22%3A%22vkey.GetVkeyServer%22%2C%22method%22%3A%22CgiGetVkey%22%2C%22param%22%3A%7B%22guid%22%3A%221399367235%22%2C%22' \
             'songmid%22%3A%5B%22{}%22%5D%2C%22songtype%22%3A%5B0%5D%2C%22uin%22%3A%223320795610%22%2C%22loginflag%22%3A1%2C%22platform%' \
             '22%3A%2220%22%7D%7D%2C%22comm%22%3A%7B%22uin%22%3A3320795610%2C%22format%22%3A%22json%22%2C%22ct%22%3A24%2C%22cv%22%3A0%7D%7D'.format(url_html,music)
        data_key=self.parse_url(html)
        link=self.html_key(data_key)
        print(link)
        print("结束!! 祝你使用愉快^_^")
        #保存
        self.with_open(link,title)

    #js加密函数
    def get_sign(self,data):
        with open('get_sign.js', 'r', encoding='utf-8') as f:
            text = f.read()
        js_data = execjs.compile(text)
        sign_id = js_data.call('get_sign', data)
        #清洗数据获取真正的sign
        sign = re.sub("finedunde", "", sign_id).replace("zzaundefined", "")
        sign = "zzaundefinedunde" + sign
        return sign
    #解析url函数
    def parse_url(self,url):

        reponse=requests.get(url=url,headers=self.headers).json()

        return reponse
    #清洗数据获取想要的参数
    def parse_data(self,response):
        music_name=[]
        music_id=[]
        #明星的名字,这是第一页,如果有要求可以自己改
        for i in range(0,80):
            music_name.append(response['singerList']['data']['singerlist'][i]['singer_name'])
            # print(music_name)
            #明星的id号
            music_id.append(response['singerList']['data']['singerlist'][i]['singer_mid'])
            # print(music_id)
        return music_id,music_name
    #歌名清洗
    def music_list(self,html_list,name):
        print("------------------------------------"+name+"的歌单------------------------------------")
        for i in range(0,10):
            print(str(i)+"  "+html_list['singerSongList']['data']['songList'][i]['songInfo']['name'])
        #这里是第3个歌
        n=int(input("请选择歌单序列号:"))
        music=html_list['singerSongList']['data']['songList'][n]['songInfo']['mid']
        music_name=html_list['singerSongList']['data']['songList'][n]['songInfo']['name']
        return music,music_name
    #链接的获取
    def html_key(self,data_key):
        req=data_key['req_0']['data']['midurlinfo'][0]['purl']
        req="https://ws.stream.qqmusic.qq.com/"+req
      #  print(req)
        return req
    #保存
    def with_open(self,link,title):
        root = './download'
        if not os.path.exists(root):
            os.mkdir(root)
        res=requests.get(link, headers=self.headers).content
        with open(os.path.join(root, '{}.mp3'.format(title)),'wb') as f:
            f.write(res)
            print(title+' 下载成功')







if __name__ == '__main__':
    qq_music=QQmusic()
    qq_music.run()

get_sign.js代码

this.window = this;
var sign = null;

!
function(n, t) {
     
    "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (n = n || self).getSecuritySign = t()
} (this,
function() {
     
    "use strict";
    var n = function() {
     
        if ("undefined" != typeof self) return self;
        if ("undefined" != typeof window) return window;
        if ("undefined" != typeof global) return global;
        throw new Error("unable to locate global object")
    } ();
    n.__sign_hash_20200305 = function(n) {
     
        function l(n, t) {
     
            var o = (65535 & n) + (65535 & t);
            return (n >> 16) + (t >> 16) + (o >> 16) << 16 | 65535 & o
        }
        function r(n, t, o, e, u, p) {
     
            return l((i = l(l(t, n), l(e, p))) << (r = u) | i >>> 32 - r, o);
            var i, r
        }
        function g(n, t, o, e, u, p, i) {
     
            return r(t & o | ~t & e, n, t, u, p, i)
        }
        function a(n, t, o, e, u, p, i) {
     
            return r(t & e | o & ~e, n, t, u, p, i)
        }
        function s(n, t, o, e, u, p, i) {
     
            return r(t ^ o ^ e, n, t, u, p, i)
        }
        function v(n, t, o, e, u, p, i) {
     
            return r(o ^ (t | ~e), n, t, u, p, i)
        }
        function t(n) {
     
            return function(n) {
     
                var t, o = "";
                for (t = 0; t < 32 * n.length; t += 8) o += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
                return o
            } (function(n, t) {
     
                n[t >> 5] |= 128 << t % 32,
                n[14 + (t + 64 >>> 9 << 4)] = t;
                var o, e, u, p, i, r = 1732584193,
                f = -271733879,
                h = -1732584194,
                c = 271733878;
                for (o = 0; o < n.length; o += 16) r = g(e = r, u = f, p = h, i = c, n[o], 7, -680876936),
                c = g(c, r, f, h, n[o + 1], 12, -389564586),
                h = g(h, c, r, f, n[o + 2], 17, 606105819),
                f = g(f, h, c, r, n[o + 3], 22, -1044525330),
                r = g(r, f, h, c, n[o + 4], 7, -176418897),
                c = g(c, r, f, h, n[o + 5], 12, 1200080426),
                h = g(h, c, r, f, n[o + 6], 17, -1473231341),
                f = g(f, h, c, r, n[o + 7], 22, -45705983),
                r = g(r, f, h, c, n[o + 8], 7, 1770035416),
                c = g(c, r, f, h, n[o + 9], 12, -1958414417),
                h = g(h, c, r, f, n[o + 10], 17, -42063),
                f = g(f, h, c, r, n[o + 11], 22, -1990404162),
                r = g(r, f, h, c, n[o + 12], 7, 1804603682),
                c = g(c, r, f, h, n[o + 13], 12, -40341101),
                h = g(h, c, r, f, n[o + 14], 17, -1502002290),
                r = a(r, f = g(f, h, c, r, n[o + 15], 22, 1236535329), h, c, n[o + 1], 5, -165796510),
                c = a(c, r, f, h, n[o + 6], 9, -1069501632),
                h = a(h, c, r, f, n[o + 11], 14, 643717713),
                f = a(f, h, c, r, n[o], 20, -373897302),
                r = a(r, f, h, c, n[o + 5], 5, -701558691),
                c = a(c, r, f, h, n[o + 10], 9, 38016083),
                h = a(h, c, r, f, n[o + 15], 14, -660478335),
                f = a(f, h, c, r, n[o + 4], 20, -405537848),
                r = a(r, f, h, c, n[o + 9], 5, 568446438),
                c = a(c, r, f, h, n[o + 14], 9, -1019803690),
                h = a(h, c, r, f, n[o + 3], 14, -187363961),
                f = a(f, h, c, r, n[o + 8], 20, 1163531501),
                r = a(r, f, h, c, n[o + 13], 5, -1444681467),
                c = a(c, r, f, h, n[o + 2], 9, -51403784),
                h = a(h, c, r, f, n[o + 7], 14, 1735328473),
                r = s(r, f = a(f, h, c, r, n[o + 12], 20, -1926607734), h, c, n[o + 5], 4, -378558),
                c = s(c, r, f, h, n[o + 8], 11, -2022574463),
                h = s(h, c, r, f, n[o + 11], 16, 1839030562),
                f = s(f, h, c, r, n[o + 14], 23, -35309556),
                r = s(r, f, h, c, n[o + 1], 4, -1530992060),
                c = s(c, r, f, h, n[o + 4], 11, 1272893353),
                h = s(h, c, r, f, n[o + 7], 16, -155497632),
                f = s(f, h, c, r, n[o + 10], 23, -1094730640),
                r = s(r, f, h, c, n[o + 13], 4, 681279174),
                c = s(c, r, f, h, n[o], 11, -358537222),
                h = s(h, c, r, f, n[o + 3], 16, -722521979),
                f = s(f, h, c, r, n[o + 6], 23, 76029189),
                r = s(r, f, h, c, n[o + 9], 4, -640364487),
                c = s(c, r, f, h, n[o + 12], 11, -421815835),
                h = s(h, c, r, f, n[o + 15], 16, 530742520),
                r = v(r, f = s(f, h, c, r, n[o + 2], 23, -995338651), h, c, n[o], 6, -198630844),
                c = v(c, r, f, h, n[o + 7], 10, 1126891415),
                h = v(h, c, r, f, n[o + 14], 15, -1416354905),
                f = v(f, h, c, r, n[o + 5], 21, -57434055),
                r = v(r, f, h, c, n[o + 12], 6, 1700485571),
                c = v(c, r, f, h, n[o + 3], 10, -1894986606),
                h = v(h, c, r, f, n[o + 10], 15, -1051523),
                f = v(f, h, c, r, n[o + 1], 21, -2054922799),
                r = v(r, f, h, c, n[o + 8], 6, 1873313359),
                c = v(c, r, f, h, n[o + 15], 10, -30611744),
                h = v(h, c, r, f, n[o + 6], 15, -1560198380),
                f = v(f, h, c, r, n[o + 13], 21, 1309151649),
                r = v(r, f, h, c, n[o + 4], 6, -145523070),
                c = v(c, r, f, h, n[o + 11], 10, -1120210379),
                h = v(h, c, r, f, n[o + 2], 15, 718787259),
                f = v(f, h, c, r, n[o + 9], 21, -343485551),
                r = l(r, e),
                f = l(f, u),
                h = l(h, p),
                c = l(c, i);
                return [r, f, h, c]
            } (function(n) {
     
                var t, o = [];
                for (o[(n.length >> 2) - 1] = void 0, t = 0; t < o.length; t += 1) o[t] = 0;
                for (t = 0; t < 8 * n.length; t += 8) o[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
                return o
            } (n), 8 * n.length))
        }
        function o(n) {
     
            return t(unescape(encodeURIComponent(n)))
        }
        return function(n) {
     
            var t, o, e = "0123456789abcdef",
            u = "";
            for (o = 0; o < n.length; o += 1) t = n.charCodeAt(o),
            u += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
            return u
        } (o(n))
    },
    function r(f, h, c, l, g) {
     
        g = g || [[this], [{
     }]];
        for (var t = [], o = null, n = [function() {
     
            return ! 0
        },
        function() {
     },
        function() {
     
            g.length = c[h++]
        },
        function() {
     
            g.push(c[h++])
        },
        function() {
     
            g.pop()
        },
        function() {
     
            var n = c[h++],
            t = g[g.length - 2 - n];
            g[g.length - 2 - n] = g.pop(),
            g.push(t)
        },
        function() {
     
            g.push(g[g.length - 1])
        },
        function() {
     
            g.push([g.pop(), g.pop()].reverse())
        },
        function() {
     
            g.push([l, g.pop()])
        },
        function() {
     
            g.push([g.pop()])
        },
        function() {
     
            var n = g.pop();
            g.push(n[0][n[1]])
        },
        function() {
     
            g.push(g[g.pop()[0]][0])
        },
        function() {
     
            var n = g[g.length - 2];
            n[0][n[1]] = g[g.length - 1]
        },
        function() {
     
            g[g[g.length - 2][0]][0] = g[g.length - 1]
        },
        function() {
     
            var n = g.pop(),
            t = g.pop();
            g.push([t[0][t[1]], n])
        },
        function() {
     
            var n = g.pop();
            g.push([g[g.pop()][0], n])
        },
        function() {
     
            var n = g.pop();
            g.push(delete n[0][n[1]])
        },
        function() {
     
            var n = [];
            for (var t in g.pop()) n.push(t);
            g.push(n)
        },
        function() {
     
            g[g.length - 1].length ? g.push(g[g.length - 1].shift(), !0) : g.push(void 0, !1)
        },
        function() {
     
            var n = g[g.length - 2],
            t = Object.getOwnPropertyDescriptor(n[0], n[1]) || {
     
                configurable: !0,
                enumerable: !0
            };
            t.get = g[g.length - 1],
            Object.defineProperty(n[0], n[1], t)
        },
        function() {
     
            var n = g[g.length - 2],
            t = Object.getOwnPropertyDescriptor(n[0], n[1]) || {
     
                configurable: !0,
                enumerable: !0
            };
            t.set = g[g.length - 1],
            Object.defineProperty(n[0], n[1], t)
        },
        function() {
     
            h = c[h++]
        },
        function() {
     
            var n = c[h++];
            g[g.length - 1] && (h = n)
        },
        function() {
     
            throw g[g.length - 1]
        },
        function() {
     
            var n = c[h++],
            t = n ? g.slice( - n) : [];
            g.length -= n,
            g.push(g.pop().apply(l, t))
        },
        function() {
     
            var n = c[h++],
            t = n ? g.slice( - n) : [];
            g.length -= n;
            var o = g.pop();
            g.push(o[0][o[1]].apply(o[0], t))
        },
        function() {
     
            var n = c[h++],
            t = n ? g.slice( - n) : [];
            g.length -= n,
            t.unshift(null),
            g.push(new(Function.prototype.bind.apply(g.pop(), t)))
        },
        function() {
     
            var n = c[h++],
            t = n ? g.slice( - n) : [];
            g.length -= n,
            t.unshift(null);
            var o = g.pop();
            g.push(new(Function.prototype.bind.apply(o[0][o[1]], t)))
        },
        function() {
     
            g.push(!g.pop())
        },
        function() {
     
            g.push(~g.pop())
        },
        function() {
     
            g.push(typeof g.pop())
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] == g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] === g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] > g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] >= g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] << g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] >> g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] >>> g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] + g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] - g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] * g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] / g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] % g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] | g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] & g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] ^ g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] in g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] instanceof g.pop()
        },
        function() {
     
            g[g[g.length - 1][0]] = void 0 === g[g[g.length - 1][0]] ? [] : g[g[g.length - 1][0]]
        },
        function() {
     
            for (var e = c[h++], u = [], n = c[h++], t = c[h++], p = [], o = 0; o < n; o++) u[c[h++]] = g[c[h++]];
            for (var i = 0; i < t; i++) p[i] = c[h++];
            g.push(function n() {
     
                var t = u.slice(0);
                t[0] = [this],
                t[1] = [arguments],
                t[2] = [n];
                for (var o = 0; o < p.length && o < arguments.length; o++) 0 < p[o] && (t[p[o]] = [arguments[o]]);
                return r(f, e, c, l, t)
            })
        },
        function() {
     
            t.push([c[h++], g.length, c[h++]])
        },
        function() {
     
            t.pop()
        },
        function() {
     
            return !! o
        },
        function() {
     
            o = null
        },
        function() {
     
            g[g.length - 1] += String.fromCharCode(c[h++])
        },
        function() {
     
            g.push("")
        },
        function() {
     
            g.push(void 0)
        },
        function() {
     
            g.push(null)
        },
        function() {
     
            g.push(!0)
        },
        function() {
     
            g.push(!1)
        },
        function() {
     
            g.length -= c[h++]
        },
        function() {
     
            g[g.length - 1] = c[h++]
        },
        function() {
     
            var n = g.pop(),
            t = g[g.length - 1];
            t[0][t[1]] = g[n[0]][0]
        },
        function() {
     
            var n = g.pop(),
            t = g[g.length - 1];
            t[0][t[1]] = n[0][n[1]]
        },
        function() {
     
            var n = g.pop(),
            t = g[g.length - 1];
            g[t[0]][0] = g[n[0]][0]
        },
        function() {
     
            var n = g.pop(),
            t = g[g.length - 1];
            g[t[0]][0] = n[0][n[1]]
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] < g.pop()
        },
        function() {
     
            g[g.length - 2] = g[g.length - 2] <= g.pop()
        }];;) try {
     
            for (; ! n[c[h++]](););
            if (o) throw o;
            return g.pop()
        } catch(n) {
     
            var e = t.pop();
            if (void 0 === e) throw n;
            o = n,
            h = e[0],
            g.length = e[1],
            e[2] && (g[e[2]][0] = o)
        }
    } (120731, 0, [21, 34, 50, 100, 57, 50, 102, 50, 98, 99, 101, 52, 54, 97, 52, 99, 55, 56, 52, 49, 57, 54, 57, 49, 56, 98, 102, 100, 100, 48, 48, 55, 55, 102, 2, 10, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 4, 21, 427, 54, 2, 15, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 61, 10, 9, 48, 61, 11, 9, 48, 61, 12, 9, 48, 61, 13, 9, 48, 61, 14, 9, 48, 61, 10, 9, 55, 54, 97, 54, 98, 54, 99, 54, 100, 54, 101, 54, 102, 54, 103, 54, 104, 54, 105, 54, 106, 54, 107, 54, 108, 54, 109, 54, 110, 54, 111, 54, 112, 54, 113, 54, 114, 54, 115, 54, 116, 54, 117, 54, 118, 54, 119, 54, 120, 54, 121, 54, 122, 54, 48, 54, 49, 54, 50, 54, 51, 54, 52, 54, 53, 54, 54, 54, 55, 54, 56, 54, 57, 13, 4, 61, 11, 9, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 102, 54, 108, 54, 111, 54, 111, 54, 114, 14, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 114, 54, 97, 54, 110, 54, 100, 54, 111, 54, 109, 14, 25, 0, 3, 4, 9, 11, 3, 3, 9, 11, 39, 3, 1, 38, 40, 3, 3, 9, 11, 38, 25, 1, 13, 4, 61, 12, 9, 55, 13, 4, 61, 13, 9, 3, 0, 13, 4, 4, 3, 13, 9, 11, 3, 11, 9, 11, 66, 22, 306, 4, 21, 422, 24, 4, 3, 14, 9, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 102, 54, 108, 54, 111, 54, 111, 54, 114, 14, 55, 54, 77, 54, 97, 54, 116, 54, 104, 8, 55, 54, 114, 54, 97, 54, 110, 54, 100, 54, 111, 54, 109, 14, 25, 0, 3, 10, 9, 55, 54, 108, 54, 101, 54, 110, 54, 103, 54, 116, 54, 104, 15, 10, 40, 25, 1, 13, 4, 61, 12, 9, 6, 11, 3, 10, 9, 3, 14, 9, 11, 15, 10, 38, 13, 4, 61, 13, 9, 6, 11, 6, 5, 1, 5, 0, 3, 1, 38, 13, 4, 61, 0, 5, 0, 43, 4, 21, 291, 61, 3, 12, 9, 11, 0, 3, 9, 9, 49, 72, 0, 2, 3, 4, 13, 4, 61, 8, 9, 21, 721, 3, 2, 8, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 4, 55, 54, 115, 54, 101, 54, 108, 54, 102, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 510, 4, 21, 523, 22, 4, 55, 54, 115, 54, 101, 54, 108, 54, 102, 8, 10, 0, 55, 54, 119, 54, 105, 54, 110, 54, 100, 54, 111, 54, 119, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 566, 4, 21, 583, 3, 4, 55, 54, 119, 54, 105, 54, 110, 54, 100, 54, 111, 54, 119, 8, 10, 0, 55, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 626, 4, 21, 643, 25, 4, 55, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 8, 10, 0, 55, 54, 69, 54, 114, 54, 114, 54, 111, 54, 114, 8, 55, 54, 117, 54, 110, 54, 97, 54, 98, 54, 108, 54, 101, 54, 32, 54, 116, 54, 111, 54, 32, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 101, 54, 32, 54, 103, 54, 108, 54, 111, 54, 98, 54, 97, 54, 108, 54, 32, 54, 111, 54, 98, 54, 106, 54, 101, 54, 99, 54, 116, 27, 1, 23, 56, 0, 49, 444, 0, 0, 24, 0, 13, 4, 61, 8, 9, 55, 54, 95, 54, 95, 54, 103, 54, 101, 54, 116, 54, 83, 54, 101, 54, 99, 54, 117, 54, 114, 54, 105, 54, 116, 54, 121, 54, 83, 54, 105, 54, 103, 54, 110, 15, 21, 1126, 49, 2, 14, 3, 2, 9, 48, 61, 3, 9, 48, 61, 4, 9, 48, 61, 5, 9, 48, 61, 6, 9, 48, 61, 7, 9, 48, 61, 8, 9, 48, 61, 9, 9, 48, 61, 10, 9, 48, 61, 11, 9, 48, 61, 9, 9, 55, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 105, 54, 111, 54, 110, 8, 10, 30, 55, 54, 117, 54, 110, 54, 100, 54, 101, 54, 102, 54, 105, 54, 110, 54, 101, 54, 100, 32, 28, 22, 862, 21, 932, 21, 4, 55, 54, 108, 54, 111, 54, 99, 54, 97, 54, 116, 54, 105, 54, 111, 54, 110, 8, 55, 54, 104, 54, 111, 54, 115, 54, 116, 14, 55, 54, 105, 54, 110, 54, 100, 54, 101, 54, 120, 54, 79, 54, 102, 14, 55, 54, 121, 54, 46, 54, 113, 54, 113, 54, 46, 54, 99, 54, 111, 54, 109, 25, 1, 3, 0, 3, 1, 39, 32, 22, 963, 4, 55, 54, 67, 54, 74, 54, 66, 54, 80, 54, 65, 54, 67, 54, 114, 54, 82, 54, 117, 54, 78, 54, 121, 54, 55, 21, 974, 50, 4, 3, 12, 9, 11, 3, 8, 3, 10, 24, 2, 13, 4, 61, 10, 9, 3, 13, 9, 55, 54, 95, 54, 95, 54, 115, 54, 105, 54, 103, 54, 110, 54, 95, 54, 104, 54, 97, 54, 115, 54, 104, 54, 95, 54, 50, 54, 48, 54, 50, 54, 48, 54, 48, 54, 51, 54, 48, 54, 53, 15, 10, 22, 1030, 21, 1087, 22, 4, 3, 13, 9, 55, 54, 95, 54, 95, 54, 115, 54, 105, 54, 103, 54, 110, 54, 95, 54, 104, 54, 97, 54, 115, 54, 104, 54, 95, 54, 50, 54, 48, 54, 50, 54, 48, 54, 48, 54, 51, 54, 48, 54, 53, 15, 3, 9, 9, 11, 3, 3, 9, 11, 38, 25, 1, 13, 4, 61, 11, 9, 3, 12, 9, 11, 3, 10, 3, 53, 3, 37, 39, 24, 2, 13, 4, 4, 55, 54, 122, 54, 122, 54, 97, 3, 11, 9, 11, 38, 3, 10, 9, 11, 38, 0, 49, 771, 2, 1, 12, 9, 13, 8, 3, 12, 4, 4, 56, 0], n);
    var t = n.__getSecuritySign;
    sign=t;
    return t;
});

function get_sign(data){
     
    return sign(data)
};

最后

代码上有很多注释,不明白的可以查看,如想爬全部可以修改我上面说的参数,这里做示范就爬一页哦~

这里还有很多可以优化的(比如多线程爬虫,和利用框架),大家可以自行修改,来让他更加的完善,这个就交给大家啦,可以有锻炼自己的机会= =(说白就是我太懒了)…

奉上图片
python爬虫实战之爬取QQ音乐_第12张图片

你可能感兴趣的:(爬虫,python,js,爬虫)