Page 1 of 1

Download a file

Posted: Sun Sep 01, 2019 8:37 pm
by Silvio.Falconi
Do you have a small script for dowload a file from a site ?

Re: Download a file

Posted: Sun Sep 01, 2019 9:37 pm
by cnavarro

Re: Download a file

Posted: Mon Sep 02, 2019 6:32 am
by ukoenig
Christobal,

I got the error unresolved external

URLDownloadToFile
I think it will work only with HARBOUR not xHARBOUR

regards
Uwe :?:

Re: Download a file

Posted: Mon Sep 02, 2019 8:07 am
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 ?

Re: Download a file

Posted: Mon Sep 02, 2019 9:30 am
by bpd2000
Hi
You have to add urlmon library

Re: Download a file

Posted: Mon Sep 02, 2019 9:39 am
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"

Re: Download a file

Posted: Mon Sep 02, 2019 10:36 am
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