这回在网络上对线重拳出击的小可爱有福了,谁再说不权威直接把这个甩他脸上。
按照第一张图片输入数字,选择模式,会自动下载榜单数据并保存至文件夹内。
[JavaScript] 纯文本查看 复制代码function p(t) {
t = encodeURIComponent(t)["replace"](/%([0-9A-F]{2})/g, function(n, t) {
return o("0x" + t)
});
try {
return btoa(t)
} catch (n) {
return Buffer["from"](t)["toString"]("base64")
}
}
function h(n, t) {
t = t || u();
for (var e = (n = n["split"](""))["length"], r = t["length"], a = "charCodeAt", i = 0; i
以下是python代码:
[Python] 纯文本查看 复制代码import requests
import execjs
from datetime import datetime
import csv
date = datetime.now().strftime("%Y-%m-%d")
with open('七麦数据.js', 'r', encoding='utf-8')as f:
ctx = execjs.compile(f.read())
data = {
"brand": "free",
"country": "cn",
"date": f'{date}',
"device": "iphone",
"genre": "36",
"page": '1'
}
host = "https://api.qimai.cn"
mode = input("请输入榜单模式数字:0.付费榜 1.免费榜 2.畅销榜 :")
url = f"/rank/indexPlus/brand_id/{mode}"
json_data = ctx.call("final", url, data)
print(json_data)
session = requests.session()
session.headers = {
"User-Agent": (
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36'
)
}
session.get("https://www.qimai.cn/rank")
page=int(input("请输入榜单页数:一页20条数据 :"))
# 下一行device可换ipad
# country和date以及snapshot皆为可变数据
def save_json_to_csv(data, filename="七麦数据.csv"):
if not data:
print("⚠️ 数据为空!")
return
# 扁平化处理(比如把 appInfo 的内容合并到主字典中)
flat_data = []
for item in data:
row = item.copy()
app_info = row.pop('appInfo', {})
row.update(app_info)
flat_data.append(row)
# 获取所有字段名
fieldnames = flat_data[0].keys()
with open(filename, mode='a', encoding='utf-8', newline='') as f:
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(flat_data)
print(f"✅ 已保存为 CSV 文件: {filename}")
for i in range(page):
final_url = host + url + "?analysis=" + json_data + f'&brand=free&device=iphone&country=cn&genre=36&date={date}&page={i + 1}&is_rank_index=1&snapshot=18:48:10'
print(final_url)
resp = session.get(final_url).json()
print(resp)
list_data = resp.get('list')
save_json_to_csv(list_data, filename="七麦数据.csv")