[Python] 纯文本查看 复制代码
import random
import time
import requests
import execjs
from fake_useragent import UserAgent
from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(max_workers=4)
headers1 = {
'User-Agent': "", #random.choice(my_headers)
'Referer': 'https://music.163.com/',
'Host': 'music.163.com',
"Nm-Gcore-Status":"1",
"Priority": "u=1, i",
"Cookie":'os=pc; osver=Microsoft-Windows-10-Professional-build-10586-64bit; appver=2.0.3.131777; channel=netease; __remember_me=true;'
}
proxy_list = []
with open('../ok_ip.txt', 'r') as f:
for line in f.readlines():
proxy_list.append(line.strip())
def fetch_data(current_ip):
def post_web(imp, url):
file = open('./wyy.js', "r").read()
js_res = execjs.compile(file)
params_seckey = js_res.call('asrseaDict', imp)
data = {
"params": params_seckey['encText'],
"encSecKey": params_seckey["encSecKey"]
}
response = session.post(url=url, headers=headers1, data=data, timeout=4).content
# response = requests.post(url=url, headers=headers1,data=data,timeout=4).content
print(f"POST:{url}\nRESPONSE:{response}")
return response
print("当前ip:", current_ip)
proxy = {"http": current_ip}
headers1["User-Agent"] = UserAgent().random
session = requests.Session() # 创建一个session对象
# 1
d1 = str({"csrf_token":""})
url1 = "https://music.163.com/weapi/cdns?csrf_token="
res1 = post_web(d1,url1)
# 2
url2 = "https://music.163.com/weapi/privacy/info/get/v2?csrf_token="
res2 = post_web(d1,url2)
# 3
url3 = "https://music.163.com/weapi/copyright/pay_fee_message/config?csrf_token="
res3 = post_web(d1, url3)
# 4
url4 = "https://music.163.com/weapi/event/user/permission?csrf_token="
res4 = post_web(d1, url4)
# 5
url5 = "https://music.163.com/weapi/privilege/message/mv?csrf_token="
res5 = post_web(d1, url5)
# 6
actionweb = '{"logs\":\"[{\\\"action\\\":\\\"activeweb\\\",\\\"json\\\":{\\\"is_organic\\\":1,\\\"url\\\":\\\"https://music.163.com/#/playlist?id=9607318306&userid=605780865\\\",\\\"mainsite\\\":\\\"1\\\"}}]\",\"csrf_token\":""}'
mobile_monitor = {"logs": "[{\"action\":\"mobile_monitor\",\"json\":{\"meta._ver\":2,\"meta._dataName\":\"pip_lyric_monitor\",\"action\":\"render\",\"userAgent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36\",\"chromeVersion\":124,\"resourceId\":2139063352,\"resourceType\":\"song\",\"mainsite\":\"1\"}}]","csrf_token": ""}
weblog = "https://music.163.com/weapi/feedback/weblog?csrf_token="
res6 = post_web(actionweb, weblog)
get_url = "https://music.163.com/m/api/encryption/param/get?csrf_token="
get_res = requests.get(url=get_url, headers=headers1,timeout=4).content
# 7
d7 = "{\"moduleName\":\"preload\",\"csrf_token\":\"\"}"
url7 = "https://music.163.com/weapi/middle/clientcfg/config/list?csrf_token="
res7 = post_web(d7, url7)
# 8
res8 = post_web(d7, url7)
# 9
# d9 = {"logs":"[{\"action\":\"mobile_monitor\",\"json\":{\"meta._ver\":2,\"meta._dataName\":\"pip_lyric_monitor\",\"action\":\"impress\",\"userAgent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36\",\"chromeVersion\":124,\"mainsite\":\"1\"}}]","csrf_token":""}
res6 = post_web(mobile_monitor, weblog)
res6 = post_web(mobile_monitor, weblog)
# 10
d10 = {"id":2139063352,"lv":-1,"tv":-1,"csrf_token":""}
url10 = "https://music.163.com/weapi/song/lyric?csrf_token="
res10 = post_web(d10, url10)
# 11
d11 = {"rid":"A_PL_0_9607318306","threadId":"A_PL_0_9607318306","pageNo":"1","pageSize":"20","cursor":"-1","offset":"0","orderType":"1","csrf_token":""}
url11 = "https://music.163.com/weapi/comment/resource/comments/get?csrf_token="
res11 = post_web(d11, url11)
res6 = post_web(mobile_monitor, weblog)
# 12
d12 = {"ids":"[2139063352]","level":"standard","encodeType":"aac","csrf_token":""}
url12 = "https://music.163.com/weapi/song/enhance/player/url/v1?csrf_token="
res12 = post_web(d12, url12)
time.sleep(2)
# 13
res12 = post_web(d12, url12)
# 14
startplay = {"logs":"[{\"action\":\"startplay\",\"json\":{\"id\":2139063352,\"type\":\"song\",\"content\":\"id=9607318306&userid=605780865\",\"mainsite\":\"1\"}}]","csrf_token":""}
res14 = post_web(startplay, weblog)
play = {"logs":"[{\"action\":\"play\",\"json\":{\"id\":\"9607318306\",\"type\":\"list\",\"mainsite\":\"1\",\"content\":\"id=9607318306&userid=605780865\"}}]","csrf_token":""}
res14 = post_web(play, weblog)
# 15
d15 = {"id":"9607318306","csrf_token":""}
url222 = "https://music.163.com/weapi/playlist/update/playcount?csrf_token="
res15 = post_web(d15, url222)
res_weblog = post_web(mobile_monitor, weblog)
# 16p[
url_16 = "https://music.163.com/weapi/activity/p2p/flow/switch/get?csrf_token="
res16 = post_web(d1, url_16)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: # 设置最大线程数
futures = {executor.submit(fetch_data, ip): ip for ip in proxy_list}
for future in concurrent.futures.as_completed(futures):
ip = futures[future]
try:
future.result() # 获取并处理每个线程的结果(如果有的话)
except Exception as exc:
print(f"线程中出现错误:{exc}, 当前使用的IP: {ip}")