【问题标题】:How to find the hidden link of mp3 files on the website | Python如何在网站上找到mp3文件的隐藏链接| Python
【发布时间】:2023-04-03 12:55:01
【问题描述】:

如何在radiojavan.com网站上通过Python找到mp3文件的隐藏链接

For example

例如,在radiojavan.com,您只能看到页面链接,但没有下载链接。我可以使用哪些工具在Python 中找到音乐链接? 请指导我。

【问题讨论】:

    标签: python beautifulsoup scrapy


    【解决方案1】:

    就像这样:

    import re
    def exp(url):
        try:
            url = url.replace('\n', '').replace('\r', '')
            op = requests.get(url , timeout=7).content
            if ".mp3" in op:
                print ("thanks it's valid link ")
                filter = re.findall('<meta property="og:audio" content="(.*?)"/>', str(op))[0]
                print ("[+] Found " + filter)
            else:
                print ('-> ' + url)
        except:
            print ("timeOut -> " + url)
            pass
    
    
    a = raw_input("link : ")
    exp(a)
    

    【讨论】:

      【解决方案2】:
      import requests
      url = 'https://www.radiojavan.com/mp3s/mp3/Hojat-Ashrafzadeh-Kaman-Abroo'
      # download page source
      r = requests.get(url)
      # convert to text
      page_source = r.text
      
      # look through each line for '.mp3'
      for line in page_source.split("\n"):
          if ".mp3" in line:
              # select the text after 'content="' and before the following '"'
              mp3url = line.strip().split('content="')[1].split('"')[0]
              print (mp3url)
      

      【讨论】:

        猜你喜欢
        • 2017-02-13
        • 1970-01-01
        • 2011-02-14
        • 2019-11-17
        • 1970-01-01
        • 2015-05-07
        • 1970-01-01
        • 2016-04-20
        • 2023-01-10
        相关资源
        最近更新 更多