|

楼主 |
发表于 2022-7-15 12:25:52
|
显示全部楼层
不知道为什么的我的帖子不见了? 想读取这个评论:https://music.163.com/#/playlist?id=925845034
- 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/103.0.0.0 Safari/537.36"
- "referer":"https://music.163.com/playlist?id=925845034"
- }
- params = "no-cache"
- data = {
- "params": params
- }
- target_url = "https://music.163.com/weapi/comment/resource/comments/get?csrf_token="
- res = requests.post(target_url, headers=headers, data=data)
- return res
- def main():
- url = input("输入网址:")
- res = get_url(url)
- with open("res.txt","w",encoding="utf-8") as file:
- file.write(res.text)
- if __name__ == " __main__":
- main()
复制代码
出现的错误是:
"referer":"https://music.163.com/playlist?id=925845034"
^
SyntaxError: invalid syntax |
|