使用python查找页面中的所有音频链接

2024-09-26 18:12:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在使用Python的站点中查找所有音频文件,如.mp3、.wav、.ogg、.wma等。 这是我的代码>;>;

    url = urllib.request.urlopen(link)
    content = url.read()
    soup = BeautifulSoup(content)
    links = [a['href'] for a in soup.find_all('a',href=re.compile('http.*\.mp3'))]
    print (str(len(links)) + " Audios Found ")
   # print (links)
    print("\n".join(links))

只能找到.mp3链接。 我还需要其他音频链接。


Tags: 代码gturl站点链接linkscontentmp3

热门问题