pythonsourceforge

Python getting files from sourceforge


Hello I am making a program, and I need it to download an exe from sourceforge. I have the download link which leads it to the "wait 5 seconds thing". How can I download the file from it, and save it to the cwd?


Solution

  • The HTML file you get contains a refresh link:

    <meta http-equiv="refresh" content="5; url=https://downloads.sourceforge.net/project/...">
    

    You can search the HTML document for that element, extract the url, then download that.

    However, remember to respect the robots.txt file. I.e. have a delay of at least one second between requests and do not try to download disallowed paths.

    Edit: Actually, the downloads subdomain has its own robots.txt that prohibits all automated downloads, so you should not do this. You could e.g. open a link in the user's web browser instead.