function urlLoad( cUrl )

User avatar
Antonio Linares
Site Admin
Posts: 42270
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

function urlLoad( cUrl )

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Carles
Posts: 1146
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: function urlLoad( cUrl )

Post by Carles »

Dear Antonio,

Concept package, Click and go ! :wink:

Nice wekend.
C.
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Lailton
Posts: 156
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Contact:

Re: function urlLoad( cUrl )

Post by Lailton »

Good Job Charly, very useful 8)
Regards,
Lailton Fernando Mariano
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: function urlLoad( cUrl )

Post 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?
Regards

G. N. Rao.
Hyderabad, India
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: function urlLoad( cUrl )

Post 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
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: function urlLoad( cUrl )

Post 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: function urlLoad( cUrl )

Post by nageswaragunupudi »

With Image URL
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: function urlLoad( cUrl )

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: function urlLoad( cUrl )

Post 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: function urlLoad( cUrl )

Post 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.
User avatar
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: function urlLoad( cUrl )

Post by Otto »

Enrico, here how I use it with web:


https://forums.fivetechsupport.com/view ... 45&t=44242

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Ruth
Posts: 172
Joined: Fri Dec 07, 2007 1:26 pm
Contact:

Re: function urlLoad( cUrl )

Post 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.
Post Reply