esullivan

Downloading files from URLs

12 posts in this topic

I am making a script, for fun, that downloads all the standard software I use when I need to reinstall my OS (A checklist if you will).  For some programs, the link will just download the newest version.  Steam for example is https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe, which makes it really easy.  Some on the other hand use the version number in the Url like Notepad++ which is https://notepad-plus-plus.org/repository/6.x/6.8.5/npp.6.8.5.Installer.exe.

Anyone have any tips on getting around this, other than launching a browser to the download site?

 

Thanks!

Share this post


Link to post
Share on other sites



; You need the following functions:

FileReadToArray ; For getting the download links
InetGet ; To download the files in the background

TD ;)


Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Sorry, I have been using InetGet, and it works, but how would I add the url since it will change with newer versions?

Edited by esullivan
Add

Share this post


Link to post
Share on other sites
$sVersion = "6.8.5" ; Change this to adjust the version to download
$sURL = "https://notepad-plus-plus.org/repository/" & StringLeft($sVersion, 1) & ".x/" & $sVersion & "/npp." & $sVersion & ".Installer.exe"

MsgBox(0, 0, $sURL)

TD :)


Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Yea, I assumed that, but then I have to look for and adjust 10 version numbers.  Might as well go to each site and download them without a script.

Was wondering if someone had a trick.  Wildcards or something like below?

$sURL = "https://notepad-plus-plus.org/repository/" & StringLeft(*, 1) & ".x/" & * & "/npp." & $* & ".Installer.exe"

Share this post


Link to post
Share on other sites

May be a donwload (with INetGet etc.) of the websites and a RegEx helps to find the correct URL's.

Share this post


Link to post
Share on other sites

@esullivan  ¯\_(ツ)_/¯


Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

I take it that's a no? HA  Thanks!

Share this post


Link to post
Share on other sites

First your url is "https://notepad-plus-plus.org/repository/"

Read that with InetRead

Parse out the last in the list which is "6.x/" so append your url

"https://notepad-plus-plus.org/repository/6.x/"

Do same for that pagr and append url

"https://notepad-plus-plus.org/repository/6.x/6.8/"

Now you can parse out the installer link from that page, but you already have all the info you need to derive

"https://notepad-plus-plus.org/repository/6.x/6.8/npp.6.8.Installer.exe"


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thanks JohnOne,  Can you give example code for that?  Just one is good.

Is it possible to read url source code without opening the site in a browser?  In the source for http://www.videolan.org/vlc/download-windows.html if I could search for "

Download latest VLC -" I could get the text just after that?

Share this post


Link to post
Share on other sites

This code works:

#Include <String.au3>
#include <INet.au3>
$s_URL = "http://www.videolan.org/vlc/download-windows.html"
$source = _INetGetSource ($s_URL)
$url = _StringBetween($source, '<h1>Download latest VLC - ', '</h1>')
MsgBox(0, "out", $url[0])

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now