0

I am learning python, I am building a small tool to download music files through python. I have two questions.

  1. The following webpage has three download links. http://mp3monkey.net/audiod/147455106/186823954/Zeds_Dead_-Demons_.mp3
    If I click on the second one (green), an mp3 file gets downloaded on my computer.
    However, that download link points to the following link. http://mp3monkey.net/audio/147455106/186823954/Zeds_Dead_-Demons_.mp3?dl=2
    If I try to open that link on a separate tab, it does not work, the webpage says "Hotlink Protection. Visit our Website Directly to Download the Song". What is happening? Why clicking directly on the download button downloads the file while open the same link on a new tab is unable to download it?

  2. I was reading the following post How do I download a file over HTTP using Python? This method does not work on the above link. Any idea why?

    import urllib

    urllib.urlretrieve("second link", "test.mp3")

    This downloads a corrupt file of size 11kb.

Community
  • 1
  • 1
  • Probably because the site doesn't have a direct link to the file, it's generated via javascript, so it can check some security issues and only after that it redirects you to the generated link. – dfranca Aug 19 '14 at 09:24
  • *"method does not work"* - errors? Unexpected behaviour? Where is the [minimal example](http://stackoverflow.com/help/mcve) of your implementation, and a description of the problem? – jonrsharpe Aug 19 '14 at 09:26
  • @danielfranca Ok, so how can I get the final "generated" link? – Ashwin Kumar Aug 19 '14 at 10:51
  • @jonrsharpe I have added the implementation and the problem. – Ashwin Kumar Aug 19 '14 at 10:56
  • You can try something like this solution: http://stackoverflow.com/questions/8960288/get-page-generated-with-javascript-in-python That means, using Selenium to open the page and click the button automatically. PS: Never tried something like this – dfranca Aug 19 '14 at 12:33

0 Answers0