马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码:import requests
from bs4 import BeautifulSoup
def get(url):
name_id = url.split('=')[1]
target_url = 'https://music.163.com/weapi/v1/resource/comments/R_SO_4_{}?csrf_token='.format(name_id)
headers = {
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36'
'referer' : 'https://music.163.com/song?id=4466775'}
params = "9YG+5zq3sUuYQg62cQRWxBtX4QYVGM1knJfkt+CYgGg/0PpmB4lPrxqbrrvj3/a4KzYya1qlNEqvU0JST2zUKrF80cxmSl6hPBN1qF62G25kDJ5D23QLNuBqc6VmtwgkGx/5jntAsPcemls5+opYWw0NyXxrUQy5wV0ZtLwEa0CgUDbH2jL0ywwYXqgGQnoR"
encSecKey = "b2c028bb694798fc32695fa27ba261adf0fce2f48d365a7fe51f7b9a47e5694cc095d715c2df7c20c2022089ab279d72ab73d897ee949656c96581b8bfeb076f8eca6c62cfca9859004ad384206e0bf6d2a6e93d060560065e1a819eea1c44dcb0b261e80b00052846851be118f2f2b5c9fbc8d93e8e1f23423ae287d029fa9d"
data = {
"params":params,
"encSecKey":encSecKey
}
res = requests.post(target_url,headers=headers,data=data)
return res
def main():
url = input("请输入链接:")
res = get(url)
with open("test1.txt",'w',encoding="utf-8") as file:
file.write(res.text)
if __name__== "__main__":
main()
报错:invalid syntax
|