Page 1 of 2
function urlLoad( cUrl )
Posted: Fri Feb 16, 2024 7:10 pm
by Antonio Linares
Thanks to Charly (Carles Aubia)
Code: Select all | Expand
#include "hbcurl.ch"
function Main()
? urlLoad( "https://raw.githubusercontent.com/FiveTechSoft/harbourPackages/main/python/init.prg" )
return nil
function urlLoad( cUrl )
local hCurl, nRet
if ! Empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_DOWNLOAD )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_FOLLOWLOCATION )
curl_easy_setopt( hCurl, HB_CURLOPT_FILETIME, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_FILE_SETUP, SubStr( cUrl, RAt( "/", cUrl ) + 1 ) )
curl_easy_setopt( hCurl, HB_CURLOPT_NOPROGRESS, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_FAILONERROR , .T. )
nRet = curl_easy_perform( hCurl )
curl_easy_cleanup( hCurl )
endif
return nRet
Re: function urlLoad( cUrl )
Posted: Fri Feb 16, 2024 8:23 pm
by Carles
Dear Antonio,
Concept package, Click and go !
Nice wekend.
C.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 12:56 am
by Lailton
Good Job Charly, very useful
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 8:55 am
by nageswaragunupudi
Code: Select all | Expand
#include "fivewin.ch"
function Main()
cUrl := "https://raw.githubusercontent.com/FiveTechSoft/harbourPackages/main/python/init.prg"
? WebPageContents( cUrl ) // --> "// dummy file"
return nil
Is this not correct?
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 9:21 am
by Enrico Maria Giordano
Or this?
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
? URLDOWNLOADTOFILE( "https://www.emagsoftware.it/logo.png", "emaglogo.png" ) = 0
RETURN NIL
#pragma BEGINDUMP
#include "hbapi.h"
#include "urlmon.h"
#include "wininet.h"
HB_FUNC( URLDOWNLOADTOFILE )
{
DeleteUrlCacheEntry( hb_parc( 1 ) );
hb_retnl( URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) );
}
#pragma ENDDUMP
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 11:18 am
by Otto
Hello friends,
After it appears that cURL is becoming increasingly important and widespread, I am posting some information on the cURL Lib here, which I created with the help of ChatGPT.
https://mybergland.com/fwforum/curl-lib.pdf
Interestingly, I just used this function yesterday as well, but from PHP, to call mod harbour.
https://forums.fivetechsupport.com/view ... 45&t=44242
Best regards,
Otto
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 11:24 am
by Enrico Maria Giordano
I don't like it. It requires a 4 MB DLL! Or am I wrong?
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 12:01 pm
by nageswaragunupudi
With Image URL
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 12:07 pm
by Enrico Maria Giordano
There are many ways to skin the cat.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 1:19 pm
by nageswaragunupudi
Both the functions WebPageContents() and URLDownloadToFile() work only on Windows OS.
For Web Applications, we need platform independent tools and CURL seems to be the popular choice.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 1:21 pm
by karinha
Enrico Maria Giordano wrote:Or this?
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
? URLDOWNLOADTOFILE( "https://www.emagsoftware.it/logo.png", "emaglogo.png" ) = 0
RETURN NIL
#pragma BEGINDUMP
#include "hbapi.h"
#include "urlmon.h"
#include "wininet.h"
HB_FUNC( URLDOWNLOADTOFILE )
{
DeleteUrlCacheEntry( hb_parc( 1 ) );
hb_retnl( URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) );
}
#pragma ENDDUMP
Dear Enrico, que me falta?
Code: Select all | Expand
URLLOAD2.c:
Turbo Incremental Link 6.97 Copyright (c) 1997-2022 Embarcadero Technologies, Inc.
Error: Unresolved external 'DeleteUrlCacheEntry' referenced from C:\FWH1905\SAMPLES\URLLOAD2.OBJ
Error: Unresolved external 'URLDownloadToFileA' referenced from C:\FWH1905\SAMPLES\URLLOAD2.OBJ
Error: Unable to perform link
* Linking errors *
Regards, saludos.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 2:06 pm
by Enrico Maria Giordano
You have to link wininet.lib from your C compiler.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 2:09 pm
by Enrico Maria Giordano
nageswaragunupudi wrote:Both the functions WebPageContents() and URLDownloadToFile() work only on Windows OS.
For Web Applications, we need platform independent tools and CURL seems to be the popular choice.
I never needed of such a function for web applications.
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 2:55 pm
by Otto
Enrico, here how I use it with web:
https://forums.fivetechsupport.com/view ... 45&t=44242
Best regards,
Otto
Re: function urlLoad( cUrl )
Posted: Sat Feb 17, 2024 4:45 pm
by Ruth
Dear friends,
please can you help me...I try to follow along and was busy reading what I found in our manual folder (fwfun.chm, fwcmd.chm, fwclass.chm,...).
Now I am curios about XImage(), WebpageContents() where could I find out more about these interesting things? Maybe someone would be kind enough to point me to a wiki for these?
Kind regards to all of you and a thank you - also to those who wrote the wonderful documentations ... they are of immense value - as the forum is.