In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how Python crawls cool music songs". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to climb cool my music songs by Python".
target
Victim address
Http://www.kuwo.cn/ development tools
Python 3.6.5
Pycharm
Start crawler code
Import module
Import requestsimport time
Parsing web pages
Interface data parameters
The three parameters of rid, t and reqld of each song will change.
Rid: the id of the song
T: timestamp
Reqid: I don't know what can be treated as unchanged.
Get the real address of the song
1import requests 2for page in range (1,11): 3 print ('= downloading song on page {} = '.format (page)) 4 url=' https://www.kuwo.cn/api/www/bang/bang/musicList?bangId=93&pn={}&rn=30&httpsStatus=1&reqId=d6378280-089a-11eb-84db-b5d33ec180f3'.format(page) 5 response = requests.get (url=url Headers=headers) 6 html_data = response.json () 7 result = html_data ['data'] [' musicList'] 8 9 for i in result:10 rid = I ['rid'] 11 name = I [' name']
Save data
1page_url = 'https://www.kuwo.cn/url?format=mp3&rid={}&response=url&type=convert_url3&br=128kmp3&from=web&t=1602074319463&httpsStatus=1&reqId=06a89771-089a-11eb-84db-b5d33ec180f3'.format(rid) 2response_2 = requests.get (url=page_url, headers=headers) 3page_data = response_2.json () 4download_url = page_data [' url'] 5def download (url Name): 6 filename ='D:\\ python\\ demo\\ Cool my Music\\ + name + '.mp3' 7 response_3 = requests.get (url=url) 8 with open (filename) Mode='wb') as f: 9 f.write (response_3.content) 10 print ('song {} has been downloaded' .format (name)) 1 for complete code, please follow the official account of Wechat: squirrel loves cookies 1 "send a message 'Cool I' to get it.
At this point, I believe you have a deeper understanding of "how Python crawls Cool my Music songs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.