Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
download file from url
#1
Hi folks

I know how to download with the direct link, but we always have updates.

import requests

print ('Download')

url = 'https://github.com/roundcube/roundcubemail/releases/download/1.4.9/roundcubemail-1.4.9-complete.tar.gz'

r = requests.get (url)

filename = url.split ('/') [- 1]

with open (filename, 'wb') as output_file:
     output_file.write (r.content)

print ('Download Completed')
How can I download the latest version without having to copy the link and edit my script.

Could you please help me?

Best Regards
Reply
#2
use

url = 'https://github.com/roundcube/roundcubemail/archive/master.zip'
Reply
#3
(Oct-27-2020, 06:53 PM)Axel_Erfurt Wrote: use

url = 'https://github.com/roundcube/roundcubemail/archive/master.zip'

Thank you Axel_Erfurt

But, master.zip is just a snapshot from the GIT repository and is **Not A STABLE
version of Roundcube**. It's not recommended to replace an existing installation
of Roundcube with this version.

There must be a way for the script to download the latest version
Reply
#4
Something like:

import requests

REPO_NAME = "roundcube/roundcubemail"
GITHUB_URL = "https://api.github.com/repos/"

latest = requests.get(f"{GITHUB_URL}{REPO_NAME}/releases/latest").json()
download_url = [x["browser_download_url"] for x in latest["assets"]
                    if x["name"].endswith("complete.tar.gz")][0]
print(f"Download URL is {download_url}")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  FTP Download of Last File jland47 4 383 Mar-16-2024, 09:15 AM
Last Post: Pedroski55
  download a file from a URL JayManPython 7 1,342 Jun-28-2023, 07:52 AM
Last Post: JayManPython
  FTP File Download question / concern cubangt 3 1,305 Jan-06-2022, 07:46 PM
Last Post: cubangt
  download with internet download manager coral_raha 0 2,941 Jul-18-2021, 03:11 PM
Last Post: coral_raha
  Download file from Private GitHub rep vinuvt 0 1,968 Jul-27-2020, 11:38 AM
Last Post: vinuvt
  PyDrive download file path MiniMinnow 0 3,234 Apr-28-2020, 03:01 PM
Last Post: MiniMinnow
  download file from google drive .. evilcode1 7 13,814 Sep-21-2018, 06:13 PM
Last Post: evilcode1
  Download entire web pages and save them as html file with urllib.request fyec 2 14,682 Jul-13-2018, 10:12 AM
Last Post: Larz60+
  download dataset from SH file Felix 1 2,590 Mar-28-2018, 05:04 AM
Last Post: Larz60+
  Download file from Internet Tribunal 1 2,771 Oct-11-2017, 06:03 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020