Sign in to follow this  
Followers 0
beernuts

Sequential file downloader using wget and autoit

1 post in this topic

Here's a file downloader I wrote that uses wget because I couldn't get inetget or curl to work right with my gui. You have to have wget for it to work. This script uses three input boxes on my gui, in one I type the number of files in the sequence, another box has the url of the first file, and the third is my output folder. It should work with most files and sequences. This code is basically finished, I was just wondering if anyone had any suggestions. I've only been coding for a few days now and it's very possible I'm doing something extremely stupid. There's a lot of string commands because I wanted each download batch to have a random number before the file extension.

Func downloadurl()

$wget = "C:\wget\wget.exe"
$numfiles = ControlGetText("My Gui" , "" , "Edit5") 
$inputurl = ControlGetText("My Gui" , "" , "Edit4")
$outputfolder = ControlGetText("My Gui" , "" , "Edit3")
$randomnumber = Random(200 , 1000 , 1)
$Lurl = StringLen($inputurl) ;lenghth of input url
$findslash = StringInStr($inputurl, "/", 0,-1) ;where the last slash is from the left
$findperiod = StringInStr($inputurl, ".", 0,-1); where the last period is from the left
$filenameX = StringTrimLeft($inputurl, $findslash)
$X = StringTrimLeft($inputurl, $findperiod - 1)
$LfilenameX = StringLen($filenameX)
$LX = StringLen($X)
$filenameNoX = StringTrimRight($filenameX, $LX )
$baseleech = StringTrimRight($inputurl, $LX +1) ;should be original url, - extension - 1 more number
$baseleech2 = StringTrimRight($inputurl, $LX +2)
run($wget & " "& $inputurl &" -O " & $outputfolder & "\" & $filenameNoX & $randomnumber + 1 & $X)
ProcessWaitClose("wget.exe")
for $b = 2 to $numfiles 
ProcessWaitClose("wget.exe")
run($wget & " "& $baseleech & $b & $X & " -O " & $outputfolder & "\" & $filenameNoX & $randomnumber + $b & $X)
sleep(1000)
if $b > 8 and $filenameNoX = "1" then $baseleech = $baseleech ; only works for 1-99
if $b > 8 and $filenameNoX <> "1" then $baseleech = $baseleech2 ;only works for 01-99
Next
run("explorer.exe" & " " & $outputfolder)

EndFunc

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
Sign in to follow this  
Followers 0