Python加密破解爬取七麦数据网APP榜单数据

免责声明
七麦数据(原ASO100)是七麦科技推出的国内专业的移动应用数据分析平台,是国内同时打通App数据、微信公众号数据、小程序数据的数据分析平台。
软件均仅用于学习交流,请勿用于任何商业用途!感谢你们!
javascript

运行环境

Version: Python3html

获取qimai_jsdata.js

点这里java

Python代码

# !/user/bin/env python
# -*- coding:utf-8 -*- 
# time: 2020/08/24---17:07
__author__ = 'Hefengyang'

''' 项目:七麦数据彻底版 榜单分类:brand_id/{}---2:畅销榜 1: 免费榜 0:付费榜 '''

import requests,execjs,json,base64,time

with open('qimai_jsdata.js', encoding='utf-8') as f:
    jsdata = f.read()
jsdata = execjs.compile(jsdata)


# 只须要传入url(brand_id)和params(筛选条件)
headers = {
    "Accept": "application/json, text/plain, */*",
    "Referer": "https://www.qimai.cn/rank",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/59.0",
    "cookie": "你登陆七麦生成的cookie"
}

api_domain = 'https://api.qimai.cn'
url = '/rank/indexPlus/brand_id/1'

params = {
    'brand':'all',
    'device':'iphone',
    'country':'cn',
    'genre':'5000',
    'date':'2020-08-24',
}

params_str = []
for i in params:
    params_str.append(params[i])
# print(params_str)

# 自定义加密函数
def encrypt(a):
    e = '00000008d78d46a'
    t = len(e)
    n = len(a)
    a = list(a)
    for s in range(n):
        a[s] = chr(ord(a[s]) ^ ord(e[(s + 10) % t]))
    return ''.join(a)
    
def main():
    api_url = api_domain + url
    # iPhone 免费榜单
    # 提取查询参数值并排序
    s = "".join(sorted([str(v) for v in params.values()]))
    # Base64 Encode
    s = base64.b64encode(bytes(s, encoding="ascii"))
    # 时间差
    t = str(int((time.time() * 1000)))
    # 拼接自定义字符串
    s = "@#".join([s.decode(), api_url, t, "1"])
    # 自定义加密 & Base64 Encode
    s = base64.b64encode(bytes(encrypt(s), encoding="ascii"))
    # 拼接 URL
    params["analysis"] = s.decode()

    analysis = jsdata.call('get_analysis',api_url,params_str)
    # print(analysis)
    params['analysis'] = analysis

    html = requests.get(api_url,params=params,headers=headers)

    return html

if __name__ == '__main__':
    html = main()
    print(html.json())

下面是我请求后的结果

{
	'code': 10000,
	'msg': '成功',
	'time': '08月24日 17:23',
	'list': [{
		'index': 1,
		'appInfo': {
			'appId': '1496121983',
			'appName': '花小猪打车-出行打车全网超低一口价',
			'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple124/v4/77/dc/1b/77dc1bf4-ed47-d9da-22df-476e16989a83/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png',
			'publisher': 'Beijing HongYiBo Technology Co., Ltd',
			'country': 'cn',
			'file_size': '140687360',
			'price': '0.00',
			'continuousFirstDays': 4
		},
		'class': {
			'ranking': 1
		},
		'change': 0,
		'genre': '旅游',
		'appGenre': '应用',
		'publisher_id': '1496121982'
	}, {
		'index': 2,
		'appInfo': {
			'appId': '1012871328',
			'appName': '得物(毒)-有毒的运动X潮流X好物',
			'icon': 'https://is1-ssl.mzstatic.com/image/thumb/Purple114/v4/0c/9f/18/0c9f185c-16a8-a708-b8e0-0e844bc8fd36/source/100x100bb.jpg',
			'publisher': 'Shanghai Shi Zhuang Information Technology Co.,Ltd.',
			'country': 'cn',
			'file_size': '378606592',
			'price': '0.00'
		},
		'class': {
			'ranking': 1
		},
		'change': 0,
		'genre': '体育',
		'appGenre': '应用',
		'publisher_id': '1114287620'
	}, {
		'index': 3,
		'appInfo': {
			'appId': '1044283059',
			'appName': '拼多多-拼着买,才便宜',
			'icon': 'https://is1-ssl.mzstatic.com/image/thumb/Purple114/v4/7b/fc/36/7bfc3657-c4c4-e1bd-e98c-aedd6337e9fc/AppIcon-0-0-1x_U007emarketing-0-0-0-10-0-0-85-220.png/180x180bb.png',
			'publisher': '上海寻梦信息技术有限公司',
			'country': 'cn',
			'file_size': '224289792',
			'price': '0.00'
		},
		'class': {
			'ranking': 1
		},
		'change': 0,
		'genre': '购物',
		'appGenre': '应用',
		'publisher_id': '1044283058'
	}, {
		'index': 4,
		'appInfo': {
			'appId': '1458072671',
			'appName': '剪映 - 轻而易剪',
			'icon': 'https://is4-ssl.mzstatic.com/image/thumb/Purple114/v4/32/3b/7b/323b7bae-0bde-2e0d-dc0e-f482ecf65236/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png',
			'publisher': '深圳市脸萌科技有限公司',
			'country': 'cn',
			'file_size': '131038208',
			'price': '0.00'
		},
		'class': {
			'ranking': 1
		},
		'change': 3,
		'genre': '摄影与录像',
		'appGenre': '应用',
		'publisher_id': '764976186'
	}, {
		'index': 5,
		'appInfo': {
			'appId': '414478124',
			'appName': '微信',
			'icon': 'https://is5-ssl.mzstatic.com/image/thumb/Purple114/v4/52/25/cb/5225cb34-00d0-3798-eeb5-ac10a616225f/AppIcon-0-0-1x_U007emarketing-0-0-0-4-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png',
			'publisher': 'WeChat',
			'country': 'cn',
			'file_size': '339382272',
			'price': '0.00'
		},
		'class': {
			'ranking': 1
		},
		'change': -1,
		'genre': '社交',
		'appGenre': '应用',
		'publisher_id': '614694882'
	}, {
		'index': 6,
		'appInfo': {
			'appId': '1142110895',
			'appName': ' 抖音短视频 ', 
			'icon ':  'https: //is5-ssl.mzstatic.com/image/thumb/Purple114/v4/3a/cc/4e/3acc4e47-86dd-8b6d-63c5-5bb9f3e37f4a/AppIcon-1x_U007emarketing-0-6-0-85-220.png/180x180bb.png', 'publisher': 'Beijing Microlive Vision Technology Co., Ltd', 'country': 'cn', 'file_size': '471684096', 'price': '0.00'}, 'class': {'ranking': 2}, 'change': -1, 'genre': '摄影与录像', 'appGenre': '应用', 'publisher_id': '1170416082'}, {'index': 7, 'appInfo': {'appId': '423084029', 'appName': '美团-吃喝玩乐 尽在美团', 'icon': 'https://is3-ssl.mzstatic.com/image/thumb/Purple114/v4/96/52/da/9652da63-406e-6d8a-cd9f-d439771719cd/AppIcon-0-0-1x_U007emarketing-0-0-0-6-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png', 'publisher': '美团', 'country': 'cn', 'file_size': '299753472', 'price': '0.00'}, 'class': {'ranking': 1}, 'change': 1, 'genre': '生活', 'appGenre': '应用', 'publisher_id': '423084032'}, {'index': 8, 'appInfo': {'appId': '1039727169', 'appName': '交管12123', 'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple124/v4/c4/d7/d1/c4d7d1a3-d05d-4430-7235-e4244fcbaeea/AppIcon-1x_U007emarketing-0-4-0-0-85-220.png/180x180bb.png', 'publisher': '公安部交通管理科学研究所', 'country': 'cn', 'file_size': '100673536', 'price': '0.00'}, 'class': {'ranking': 2}, 'change': 11, 'genre': '生活', 'appGenre': '应用', 'publisher_id': '1039727168'}, {'index': 9, 'appInfo': {'appId': '590338362', 'appName': '网易云音乐-音乐的力量', 'icon': 'https://is5-ssl.mzstatic.com/image/thumb/Purple124/v4/f7/e1/23/f7e1235d-a131-d5b4-d092-4423956cb253/AppIcon-0-0-1x_U007emarketing-0-0-0-6-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png', 'publisher': '杭州网易云音乐科技有限公司', 'country': 'cn', 'file_size': '438467584', 'price': '0.00'}, 'class': {'ranking': 1}, 'change': -3, 'genre': '音乐', 'appGenre': '应用', 'publisher_id': '1202760281'}, {'index': 10, 'appInfo': {'appId': '444934666', 'appName': 'QQ', 'icon': 'https://is5-ssl.mzstatic.com/image/thumb/Purple124/v4/ea/f4/dd/eaf4dd50-9cbf-c4fe-d9ea-8cca720904d7/AppIcon-1-1x_U007emarketing-0-7-0-0-85-220.png/180x180bb.png', 'publisher': 'Tencent Technology (Shenzhen) Company Limited', 'country': 'cn', 'file_size': '514864128', 'price': '0.00'}, 'class': {'ranking': 2}, 'change': -1, 'genre': '社交', 'appGenre': '应用', 'publisher_id': '292374531'}, {'index': 11, 'appInfo': {'appId': '333206289', 'appName': '支付宝 - 生活好 支付宝', 'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple114/v4/a6/db/c1/a6dbc189-ccde-534f-1f0d-f87ca7f188c3/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-85-220.png/180x180bb.png', 'publisher': 'Alipay (Hangzhou) Technology Co., Ltd.', 'country': 'cn', 'file_size': '365416448', 'price': '0.00'}, 'class': {'ranking': 3}, 'change': -1, 'genre': '生活', 'appGenre': '应用', 'publisher_id': '333206292'}, {'index': 12, 'appInfo': {'appId': '741292507', 'appName': '小红书 – 标记个人生活', 'icon': 'https://is4-ssl.mzstatic.com/image/thumb/Purple114/v4/af/fb/11/affb1109-3d16-b901-7679-2349a3ca7683/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/180x180bb.png', 'publisher': 'Xingin', 'country': 'cn', 'file_size': '473981952', 'price': '0.00'}, 'class': {'ranking': 3}, 'change': -1, 'genre': '社交', 'appGenre': '应用', 'publisher_id': '708264912'}, {'index': 13, 'appInfo': {'appId': '387682726', 'appName': '手机淘宝 - 淘到你说好', 'icon': 'https://is4-ssl.mzstatic.com/image/thumb/Purple124/v4/e7/0d/b6/e70db610-3e6d-88ce-08d3-fac58a7f7233/AppIcon-0-1x_U007emarketing-0-9-0-0-sRGB-0-85-220.png/180x180bb.png', 'publisher': 'Taobao (China) Software CO.,LTD', 'country': 'cn', 'file_size': '471324672', 'price': '0.00'}, 'class': {'ranking': 2}, 'change': 0, 'genre': '购物', 'appGenre': '应用', 'publisher_id': '387682729'}, {'index': 14, 'appInfo': {'appId': '629774477', 'appName': '芒果TV', 'icon': 'https://is5-ssl.mzstatic.com/image/thumb/Purple114/v4/40/f1/93/40f1935d-9750-1dcf-2350-253eb73680e2/AppIcon-0-0-1x_U007emarketing-0-0-0-5-0-0-0-0-85-220.png/180x180bb.png', 'publisher': '快乐阳光', 'country': 'cn', 'file_size': '286025728', 'price': '0.00'}, 'class': {'ranking': 1}, 'change': -2, 'genre': '娱乐', 'appGenre': '应用', 'publisher_id': '367207223'}, {'index': 15, 'appInfo': {'appId': '382201985', 'appName': '百度', 'icon': 'https://is3-ssl.mzstatic.com/image/thumb/Purple124/v4/40/05/01/400501cd-b8c4-32a5-b44f-a68cd7875509/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-85-220.jpeg/180x180bb.png', 'publisher': 'Beijing Baidu Netcom Science & Technology Co.,Ltd', 'country': 'cn', 'file_size': '329801728', 'price': '0.00'}, 'class': {'ranking': 1}, 'change': 1, 'genre': '工具', 'appGenre': '应用', 'publisher_id': '372585298'}, {'index': 16, 'appInfo': {'appId': '1340376323', 'appName': '淘宝特价版 - 会省会花上特价', 'icon': 'https://is4-ssl.mzstatic.com/image/thumb/Purple114/v4/42/be/9f/42be9f00-f305-9304-d694-5b7799600133/AppIcon-0-0-1x_U007emarketing-0-0-0-7-0-0-sRGB-85-220.png/180x180bb.png', 'publisher': 'Taobao (China) Software CO.,LTD', 'country': 'cn', 'file_size': '211318784', 'price': '0.00'}, 'class': {'ranking': 3}, 'change': 2, 'genre': '购物', 'appGenre': '应用', 'publisher_id': '387682729'}, {'index': 17, 'appInfo': {'appId': '691828408', 'appName': '微视-短视频创做与分享', 'icon': 'https://is5-ssl.mzstatic.com/image/thumb/Purple114/v4/fd/df/51/fddf51be-9f10-c373-047a-7198426c4998/source/100x100bb.jpg', 'publisher': 'Tencent Technology (Beijing) Company Limited', 'country': 'cn', 'file_size': '303346688', 'price': '0.00'}, 'class': {'ranking': 3}, 'change': -3, 'genre': '摄影与录像', 'appGenre': '应用', 'publisher_id': '542280115'}, {'index': 18, 'appInfo': {'appId': '461703208', 'appName': '高德地图-精准智能导航,出行必备', 'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple124/v4/37/03/7c/37037c6c-abf3-299f-dab5-b8fedb279304/AppIcon-1x_U007emarketing-0-6-0-0-85-220.png/180x180bb.png', 'publisher': 'AutoNavi Information Technology Co. Ltd.', 'country': 'cn', 'file_size': '249520128', 'price': '0.00'}, 'class': {'ranking': 1}, 'change': 2, 'genre': '导航', 'appGenre': '应用', 'publisher_id': '300625629'}, {'index': 19, 'appInfo': {'appId': '393765873', 'appName': '爱奇艺-中国新说唱独播', 'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple114/v4/fe/df/2e/fedf2e2d-1351-f15b-6458-0c025e8b5570/AppIcon-0-1x_U007emarketing-0-5-0-0-85-220.png/180x180bb.png', 'publisher': 'QIYI', 'country': 'cn', 'file_size': '390140928', 'price': 
				'0.00'
		},
		'class': {
			'ranking': 2
		},
		'change': -2,
		'genre': '娱乐',
		'appGenre': '应用',
		'publisher_id': '387327025'
	}, {
		'index': 20,
		'appInfo': {
			'appId': '930368978',
			'appName': '钉钉',
			'icon': 'https://is2-ssl.mzstatic.com/image/thumb/Purple124/v4/06/77/91/067791fe-8849-27f3-92c0-95a99f3dcc59/AppIcon-0-0-1x_U007emarketing-0-0-0-6-0-0-sRGB-85-220.png/180x180bb.png',
			'publisher': 'DingTalk (China) Information Technology Co., Ltd.',
			'country': 'cn',
			'file_size': '392731648',
			'price': '0.00'
		},
		'class': {
			'ranking': 1
		},
		'change': 10,
		'genre': '商务',
		'appGenre': '应用',
		'publisher_id': '1435447040'
	}]
}

获取qimai_jsdata.js

点这里python