Jump to content

[Solved] Every day download file with different name


Recommended Posts

Hello everybody,

I'm new to AUTOIT and forum and sorry if this is a stupid question.

 I'd like to automatically every day download a specific file from website, but the name of the file is changing.

- website: https://www.zaba.hr/home/tecajna

- File: <a class="action-download" href="/home/ZabaUtilsWeb/utils/tecaj/txt/103/2020"><span>TXT</span></a>

- Number "103" increases every day by one.

- downloaded file: tecajna-103-2020.txt

 

Can you guys help me please.

 

Thank very much.

 

 

 

Image 1.png

Edited by marinko22
Link to comment
Share on other sites

To start you up :

#include <IE.au3>
#include <Constants.au3>

Local $oIE = _IECreate("https://www.zaba.hr/home/tecajna")
If @error Then Exit MsgBox ($MB_SYSTEMMODAL,"","Unable to load web page")
Local $oDL = _IEGetObjById ($oIE, "txt")
If @error Then Exit MsgBox ($MB_SYSTEMMODAL,"","TXT Object not found")
$oDL = _IETagNameGetCollection($oDL, "a", 0)
If @error Then Exit MsgBox ($MB_SYSTEMMODAL,"","DownLoad Object not found")
_IEAction ($oDL, "click")
Sleep (2000)
Local $hWnd= _IEPropertyGet ($oIE, "hwnd")
Local $hCtrl = ControlGetHandle ($hWnd, "", "DirectUIHWND1")
ControlSend ($hWnd, "", $hCtrl, "{F6}{TAB}")
Sleep (800)
ControlSend ($hWnd, "", $hCtrl, "{ENTER}")

 

Link to comment
Share on other sites

Or something like

 

#include <Inet.au3>
$x = _INetGetSource("https://www.zaba.hr/home/tecajna")
$pos = StringInStr($x, "/home/ZabaUtilsWeb/utils/tecaj/txt/")
$file = StringMid($x, $pos+35,8)
InetGet("https://www.zaba.hr/ZabaUtilsWeb/utils/tecaj/txt/" & $file, StringReplace($file, "/", "-") & ".txt")

 

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

  • Developers
1 minute ago, marinko22 said:

can you tell me how to define where to download a file

F1 in SciTE to open the Helpfile? 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The help file is your friend ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

InetGet("https://www.zaba.hr/ZabaUtilsWeb/utils/tecaj/txt/" & $file,  "\\c\test\" & StringReplace($file, "/", "-") & ".txt")

or 

#include <Inet.au3>
Local $sFilePath = "\\c\test\"
$x = _INetGetSource("https://www.zaba.hr/home/tecajna")
$pos = StringInStr($x, "/home/ZabaUtilsWeb/utils/tecaj/txt/")
$file = StringMid($x, $pos+35,8)
Local $hDownload =  InetGet("https://www.zaba.hr/ZabaUtilsWeb/utils/tecaj/txt/" & $file,  $sFilePath & StringReplace($file, "/", "-") & ".txt")

what do you think is better

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...