#! /usr/bin/env python # -* -coding: utF-8 -*- # @time: 2020/12/12 10:00 # @author: huni # @file: PyCharm import requests import warnings import json from urllib import parse warnings.filterwarnings('ignore') if __name__ = = "__main__ ': headers = {' referer:' https://www.kugou.com/ ', 'the user-agent' : 'Mozilla / 5.0 (Windows NT 10.0; Win64; X64) AppleWebKit / 537.36 (KHTML, Like Gecko) Chrome/86.0.4240.183 Safari/537.36'} URL = f'https://complexsearch.kugou.com/v2/search/song?callback=callback123&keyword=%E6%97%A9%E6%99%9A&page=1' \ f'&pagesize=30&bitrate=0&isfuzzy=0&tag=em&inputtype=0&platform=WebFilter&userid=-1&clientver=2000&iscorrection=1&privile ge_filter=0&srcappid=2919&clienttime=1607743429898&mid=1607743429898&uuid=1607743429898&dfid=-&signature=ED386B5C3766E47 D47F1252AED823A0F' resp = requests.get(url=url, Headers =headers). Text [12:-2] jd = json. Loads (resp) # a = i['FileHash'] b = i['AlbumID'] url1 = f'https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback' \ f'=jQuery19108991040761831859_1607742705511&hash=' \ f'{a}&dfid=334lgQ3gvzHD1503TJ1eRVym&mid=449fc6a9349f6b64fc0d58efab406b8d&platid=4&album_id' \ f'={b}&_=1607742705512' Get (url= urL1,headers=headers).text[41:-2] jd1 = json.loads(resp1) # Print (' title 'jd1 [' data'] [' audio_name ']) print (' album 'jd1 [' data'] [' album_name ']) print (' song links' jd1 [' data '] [' play_url '])Copy the code
That’s all for today’s sharing. If you’re interested in Python, please join us.Python Learning communicationSkirt 】, receive free learning materials and source code.