Python 如何在有声读物网站上捕获mp3文件的请求url?

Python 如何在有声读物网站上捕获mp3文件的请求url?,python,audio,python-requests,capture,Python,Audio,Python Requests,Capture,网站: https://www.ting22.com/ting/659-2.html 我想从上面的网站上买一些有声读物。换句话说,我想把有声读物的MP3文件从659-2.html下载到659-1724.html 通过使用F12工具,在[Network]->[Media]中,我可以看到MP3文件的请求URL,但我不知道如何使用脚本获取URL 以下是我使用的一些规格: 系统:Windows7x64 Python:3.7.0 更新: 例如,通过使用F12工具,我可以看到文件的url为“” 但我不

网站:

https://www.ting22.com/ting/659-2.html
我想从上面的网站上买一些有声读物。换句话说,我想把有声读物的MP3文件从
659-2.html
下载到
659-1724.html

通过使用F12工具,在[Network]->[Media]中,我可以看到MP3文件的请求URL,但我不知道如何使用脚本获取URL

以下是我使用的一些规格:

  • 系统:Windows7x64
  • Python:3.7.0
更新:

例如,通过使用F12工具,我可以看到文件的url为“”

但我不知道如何在代码中获取MP3文件的URL?而不是如何下载文件

我应该使用哪个图书馆

谢谢。

更新 这会有点复杂,因为请求包不会返回.mp3源代码,所以需要使用Selenium。下面是一个经过测试的解决方案:

from selenium import webdriver  # pip install selenium
import urllib3
import shutil
import os


if not os.path.exists(os.getcwd()+'/mp3_folder'):
    os.mkdir(os.getcwd()+'/mp3_folder')


def downloadFile(url=None):
    filename = url.split('/')[-1]
    c = urllib3.PoolManager()
    with c.request('GET', url, preload_content=False) as resp, open('mp3_folder/'+filename, 'wb') as out_file:
        shutil.copyfileobj(resp, out_file)
    resp.release_conn()


driver = webdriver.Chrome('chromedriver.exe')  # download chromedriver from here and place it near the script: https://chromedriver.storage.googleapis.com/72.0.3626.7/chromedriver_win32.zip
for i in range(2, 1725):
    try:
        driver.get('https://www.ting22.com/ting/659-%s.html' % i)
        src = driver.find_element_by_id('mySource').get_attribute('src')
        downloadFile(src)
        print(src)
    except Exception as exc:
        print(exc)

例如,mp3文件的url是“”;我的意思是我不知道如何从网页代码中获取url,而不知道如何下载mp3文件。你真是太好了~我发现当我单击[play]按钮时,我可以在[elements]标签中找到mp3 url,然后我可以从[elements]获取audio.src。然后我可以下载音频。我遇到了相同的问题,但我的url看起来是:,该页面只有我想要的音频,但不知道如何下载,请提供帮助