Python collection Himalayan audio, anytime, anywhere, listen I want to hear

Foreword

The text of text and images from the network, only to learn, exchange, not for any commercial purposes, belongs to original author, if any questions, please contact us for treatment.

PS: If necessary Python learning materials can be added to a small partner click the link below to obtain their own

http://note.youdao.com/noteshare?id=3054cce4add8a909e784ad934f956cef

Himalayan FM is a professional audio sharing platform that brings together audio novels, audio books, audio books, children's bedtime stories, comic sketches, ghost stories, hundreds of millions of pieces of audio. Today, we gather together to learn how to Himalayan audio. Anytime, anywhere, listen I want to hear.

Development Environment:

  1. Version: anaconda5.2.0 (python3.6.5)

  2. Editor: pycharm

Related modules:

import requests
import pprint
import re

Achieve results

Here Insert Picture Description Here Insert Picture Description

The complete code

Requests Import 
Import the pprint 
Import Re 

"" "Found bulk download Laws" "" 

# block comment 
"" "id incoming audio using an audio interface to obtain the Download" "" 

headers = { 
    '- Agent-the User': 'the Mozilla / 5.0 (the Windows NT 10.0; Win64; x64-) AppleWebKit / 537.36 (KHTML, like the Gecko) the Chrome / 77.0.3865.90 Safari / 537.36 ' 
} 


DEF download_media (song_id, sond_name): 
    # revocation selected tab shift + tab indent 
    "" "The songid name "" " 
    MEDIA_URL = 'https://www.ximalaya.com/revision/play/v1/audio?id=' + song_id + '& PTYPE = 1' 
    # forge the identity of the browser 
    response = requests.get (media_url, headers = headers) 
    # I am a python request 
    # print (response.request.headers) 
    # dictionary type 
    data = response.json ()
    Print # (Data) 
    # pprint.pprint (Data) 
    # formatted print beautiful data just use the line 
    # pprint.pprint (Data [ 'Data']) 
    mp3_url = Data [ 'Data'] [ 'the src'] 

    # video audio picture binary need to decode it? 
    = requests.get Response (mp3_url) 
    # Text text Content 
    # Print (Response) 
    with Open (sond_name + '.m4a', 'WB') AS F: 
        f.write (response.content) 
    Print (sond_name, 'downloaded' ) 


# = sond_name 'personal goddess master set of 10 real master' 
# song_id = '98,944,395' 
# download_media (song_id, sond_name) 
for I in Range (. 1, 32): 
    Response = requests.get ( 'HTTPS: // www.ximalaya.com/youshengshu/16411402/p'+str(i)+'/ ',
    name_url = re.findall('<div class="text _c2"><a title="(.*?)" href="/youshengshu/16411402/(\d+)">', response.text)
    for i in name_url:
        print(i[0], i[1])
        download_media(i[1], i[0])

  

 

Guess you like

Origin www.cnblogs.com/qun821460695/p/11829663.html