import requests
def get_comments(url):
name_id = url.split('=')[1]
headers = {
'user_agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36',
'referer':'https://music.163.com/song?id={}'.format(name_id)
}
params = 'bAlZeFbErjR3OaTk2dItfjTsyEHewPeLY2ZbyUowgmWGBu7+LPquSyuAs+5NHJrqpLQQ0WGhyAIqSqXd0ZqT6HZG1uIo8+AxxEeLqSKt1NiGaTB7YAjR4FEZXaQqwpdjPIjivqi/ECSBaONhGdhKcnUkEvAXEox7oQo4bMICXSHeOsyW8lYfIQzRkwK5PQ9g'
encSecKey = '2f6816b0e71f96e8c72fafaaa3634c23cbc43ebf5f5088b5f499e877893e98898059fed97a0fe125c9b00a44ea2996314745e91d75d4cf95f2fa26145492c401b8d02a6eb3451bb49e7df3a57d52f5ad78ae3df477b332f0e5f91df68ccc20d66fee26fd8112f52414cf9139ff74100da59e10f45009063142a4fc1438a5eeb9'
cookie = 'JSESSIONID-WYYY=OqYRslUe3vwNR5pOqud591rgdtBxstHb%5CznkpNTtMGVnjIQjz2zaEPMNgyPRW13ffDw%2Fc%2B4e5onRY7OKbGJlUlffpJs9%2FYkSF3BgUoluDHW5YaFguft3VOjhk2eSdiD9mUHoc7Zk7WFN2CC55K7%2FUh%5CwAtKPWbREEIZwHrKMfiUn9Pfk%3A1581473881430; _iuqxldmzr_=32; _ntes_nnid=5ccd50e65676e6cebfc754e7d304ba05,1581472081493; _ntes_nuid=5ccd50e65676e6cebfc754e7d304ba05; WM_NI=LXb%2BxNhlEK3VE5bmo46ZJqUWC9V1A%2FNUhPr%2BQ5xuF9FfKndK8QMmJOyL6KefwXpPC%2BDkfeZmiIKRotNmqp0ujIu3LIwchhyQ7LuHtWIhhFy8gUZSuDq5RVxfu%2BFCAU3KZU4%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6ee99dc7e869f8fa6db64b6b08aa7d45e939b8ebaaa5a93acbfa7ed54fcb484d7ce2af0fea7c3b92a9088aeccfb46acb48bacb25e87ebae8eee40f6868692d85d81e79ad2c4258e8ba8b1f12193ebb896c53386ba858fe741fc8f838ec945bb94faace86eb588c0b1c22188b5aa86d967ab9785b3ee808eb3bf91b37faa97bbd4cf43b5bda889fc5bf594bba9f75d8bb8a8a7fc34a58b96b4f850b3eb9eb7fb6eb7f58aa4c45ff19596b6b737e2a3; WM_TID=XCP%2B2fh7KoFBBUEVEBYqAE4%2FBjHolLqe'
data = {
"params":params,
"encSecKey":encSecKey,
"cookie":cookie
}
target_url = "https://music.163.com/weapi/v1/resource/comments/R_SO_4_{}?csrf_token=".format(name_id)
res = requests.post(target_url,headers=headers,data=data)
return res
def main():
url = input("请输入链接地址:")
#res = get_url(url)
res = get_comments(url)
with open("res.txt","w",encoding="utf-8") as file:
file.write(res.text)
if __name__ == "__main__":
main()