|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是我的代码:
import requests
def get_url(url):
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763',
'referer': 'http://music.163.com/'}
data={}
data['params']='sD%2BBulz7b9Pee3qxC9uWOHmghqs8CPw67WlSqOgKcJbB9iOJ3MwQp2UxUrD7YUgaxrzQ%2FsWM9bGLSi8tPJOzaayWnG5MrHKcuNEmNQft7mXb2eq7sBdWycjGcJML3QV052%2B2NOBlK%2Fk9EmXC%2Bw6hFlwkG5Iyy5UHbJtUzb11sefBO4TwW1TvQhIl%2BOclOuJU'
data['encSecKey']='8992b97e96b590e5c8c38a12ff7f3f9fb4e30741e24cbb2459e1f8b6876268b9549b4c2903111e996c58ed5d61ddaed6b10035a354666fcc9fd33ab57249caac1d2a0ff742e700ce5ccc7af91fdb7d6c0ada3de11415862ac7d8cfd6c8de0eed8c3a05f75d2f14af010e86c1c0ff0031d470c26cc06cf0acd8dbb43c9fc4a5e7'
name_id=url.split('=')[1]
target_url='https://music.163.com/weapi/v1/resource/comments/R_SO_4_{}?csrf_token='.format(name_id)#{}.format
res = requests.post(target_url, headers=headers,data=data)
return res
def main():
url = input("请输入链接地址:")
res = get_url(url)
with open("D:\\res.txt", "w", encoding="utf-8") as file:
file.write(res.text)
if __name__ == "__main__":
main()
结果是这段代码能够运行,但是得到的res.txt文件是空白的,请问这是因为什么呢?
是因为params和encSecKey这里出了问题吗(我是直接从网页上复制过来的)
|
|