Download a file

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Download a file

Post by Silvio.Falconi »

Do you have a small script for dowload a file from a site ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Download a file

Post by cnavarro »

C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Download a file

Post by ukoenig »

Christobal,

I got the error unresolved external

URLDownloadToFile
I think it will work only with HARBOUR not xHARBOUR

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Download a file

Post by Silvio.Falconi »

error with harbour

Code: Select all

Progetto: nages, Ambiente: bcc7xHarbor:
[1]:Harbour.Exe nages.prg  /m /n0 /gc1 /es2 /a /iC:\Work\fwh\include /iC:\work\XHARBOUR\Include /jI18n\Main.hil /iinclude;c:\work\fwh\include;C:\work\XHARBOUR\include /oObj\nages.c
xHarbour 1.2.3 Intl. (SimpLex) (Build 20180217)
Copyright 1999-2017, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'nages.prg'...
Generating international list to 'I18n\Main.hil'...
Generating C source output to 'Obj\nages.c'...
Done.
Lines 149, Functions/Procedures 3, pCodes 594
[1]:Bcc32.Exe -M -c -DHB_OS_WIN_32 -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -IC:\Work\fwh\include -IC:\work\bcc7\Include\windows\sdk\;C:\work\XHARBOUR\Include  -nObj Obj\nages.c
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
Obj\nages.c:
[1]:iLink32.Exe -Gn -aa -Tpe -s -v @nages.bcl
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external 'URLDownloadToFileA' referenced from C:\WORK\ERRORI\LOTTO\OBJ\NAGES.OBJ
Error: Unable to perform link
 

I tried also this source

Code: Select all

  #include "fivewin.ch"

        function Main()
                LOCAL   nRet
               
                nRet := DOWNLOADFILE( "https://www.lottomatica.it/STORICO_ESTRAZIONI_LOTTO/storico.zip", "C:\" )
               
                MsgStop( nRet )
        RETURN NIL


         #pragma BEGINDUMP

    #include <Windows.h>
    #include <hbapi.h>
    #include <urlmon.h>

    HB_FUNC( DOWNLOADFILE )

    {
            HRESULT hr;

            hr = URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) ;

            hb_retnl( hr ) ;
    }

    #pragma ENDDUMP




How decompress a file zip I downloaded ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
bpd2000
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: Download a file

Post by bpd2000 »

Hi
You have to add urlmon library
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Download a file

Post by Silvio.Falconi »

Now I foud a script run ok

Code: Select all

 #include "fivewin.ch"

function DescargFichDesdeUrl()
   Local cdate:=dtoc(date())
   local cFile := "C:\Work\Errori\download\storico_.zip"
   local cUrl  := "https://www.lottomatica.it/STORICO_ESTRAZIONI_LOTTO/storico.zip"

    DELETEURLCACHEENTRY( cUrl )

    URLDOWNLOADTOFILE( 0, cUrl, cFile )
 
RETURN NIL

DLL STATIC FUNCTION DELETEURLCACHEENTRY( cUrl AS LPSTR ) AS BOOL;
    PASCAL FROM "DeleteUrlCacheEntryA" LIB "wininet.dll"

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG, cUrl AS LPSTR, cFileName AS LPSTR, nReserved AS DWORD, nFnCB AS LONG ) AS LONG;
    PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Download a file

Post by ukoenig »

Silvio,

YES works perfect

a download-test from my website

LOCAL cSaveAs := "I:\_Download\download\Store_.zip"
LOCAL cUrl := "http://www.Pflegeplus.com/DOWNLOADS/Gditest1.zip"


regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply