七麦逆向-参数 analysis

# pip install PyExecJS
# execjs 需要安装nodejs  https://nodejs.org/en
# url="https://www.qimai.cn/"
import requests
import execjs


def get_analysis(short_url, params):
with open("qimai.js", 'r', encoding='utf-8') as f:
js_html = f.read()
js_obj = execjs.compile(js_html)
# url = "/index/banner"
# params = {
# 'cid' : 28
# }
analysis = js_obj.call('f1', short_url, params)
print(f"analysis={analysis}")
return analysis


def get_data(app_id):
headers = {
'authority': 'api.qimai.cn',
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
'origin': 'https://www.qimai.cn',
'pragma': 'no-cache',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
}
params = {
'appid': app_id,
}
short_url = "/andapp/detail"
url = f"https://api.qimai.cn{short_url}"
analysis = get_analysis(short_url, params)
params["analysis"] = analysis
response = requests.get(url, params=params, headers=headers)
print(response.json())


def search(keyword, page=1):
headers = {
'authority': 'api.qimai.cn',
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
'origin': 'https://www.qimai.cn',
'pragma': 'no-cache',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
}
params = {
"search": keyword,
"page": page,
"market": 6
}
short_url = "/search/android"
url = f"https://api.qimai.cn{short_url}"
analysis = get_analysis(short_url, params)
params["analysis"] = analysis
response = requests.get(url, params=params, headers=headers)
result=response.json()
appList=result.get("appList")
for app in appList:
print(app)


if __name__ == '__main__':
# app_id="1368993929"
# get_data(app_id)
keyword = "抖音"
search(keyword, page=1)
 

运行结果:

 

 

需要js代码的可以加微信私聊:xieake1905

posted @ 2024-02-23 19:58  冰底熊  阅读(55)  评论(0编辑  收藏  举报