Sign in to follow this  
Followers 0
Gimerly

Downloading files from a http server

11 posts in this topic

#1 ·  Posted (edited)

Hey, I really need help in downloading files from a http server. It is easy enough but I don't know how to check the contents of the folder on the server against the contents the folder I want to download the files to, to make sure that I don't download the file more than once. If any one can post some sample code to help me with my problem it would be much appreciated

Edited by Melba23
Amended title

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Welcome to the autoit forum :)

One simple way is to check if the file already exists on your computer :

; Assign a Local variable the registration path of the file to download
Local $sFile = @ScriptDir & "\myfile.txt"

; If the file does not exists locally
; You can also check if the sizes are equal using FileGetSize and InetGetSize.
If FileExists($sFile) = 0 Then
    ; Download it
    InetGet("http://example.com/myfile.txt", $sFile)
EndIf

Edit : Don't forget to read the helpfile ;)

And please use a significant thread title next time, we already know you "Need help" ;)

Br, FireFox.

Edited by FireFox
1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Thanks for the reply FireFox. I should have made myself more clear. What I need is to request a list of files from a http server so that I can compare that with my local drive files to determine whether or not I need to download the file. Currently what I am doing is downloading a file called update.txt which contains all the file names on the server. Every few minutes i re-download that text file and see if any changes have occurred and if any changes have occurred I download the newest files. All I want is to see if I can minimise the code using the former method but don't currently know if it is possible. 

Share this post


Link to post
Share on other sites

Post what you've done so far.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

These three functions will do that:

INetGet

_FileReadToArray

FileExists

 

There is example code in the Help file for each of these functions. You would also want to read and learn about loops, particularly For..Next and If..Then loops


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i tried the _FileReadToArray but I found it only worked with local files and couldn't exact the info from the site I wanted

Edited by Gimerly

Share this post


Link to post
Share on other sites

BTW:

Could you please give meaningful titles to your threads? Because everyone on this forum is looking for help ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yea sorry about that. This is the first time I have ever requested help on forums. I generally tend to look through the help files should I need a bit of information and as such I was not fully aware of how to properly structure A post 

Share this post


Link to post
Share on other sites

No big deal :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

i tried the _FileReadToArray but I found it only worked with local files and couldn't exact the info from the site I wanted

Use INetGet to get the file that's on the 'net.

Use _FileReadToArray to process each element of the local file that's the result of the first step. (this is where loops will be used..)

Use FileExists to process each element that _FileReadToArray returns.

 

There is example code in the Help file for each of these functions. You would also want to read and learn about loops, probably particularly For..Next and If..Then loops

BTW:

Could you please give meaningful titles to your threads? Because everyone on this forum is looking for help ;)

It could help someone in the future with a similar problem who is searching thru the forum if the title more accurately describes the issue.

Good Luck! :)

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I do use the INetGet function to download, but all I wanted to know is if there is a way to fetch a list of files from the server without going through the long drawn out method I use (and most likely others). I have look through all the functions in the help files and nothing can do the thing I want. Thanks for the reply's I appreciate them despite my stupid naming of the title.  

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