function urlLoad( cUrl )

function urlLoad( cUrl )

Postby Antonio Linares » Fri Feb 16, 2024 7:10 pm

Thanks to Charly (Carles Aubia)
Code: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: function urlLoad( cUrl )

Postby Carles » Fri Feb 16, 2024 8:23 pm

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
Carles
 
Posts: 1137
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: function urlLoad( cUrl )

Postby Lailton » Sat Feb 17, 2024 12:56 am

Good Job Charly, very useful 8)
Regards,
Lailton Fernando Mariano
User avatar
Lailton
 
Posts: 153
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil

Re: function urlLoad( cUrl )

Postby nageswaragunupudi » Sat Feb 17, 2024 8:55 am

Code: Select all  Expand view

#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
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: function urlLoad( cUrl )

Postby Enrico Maria Giordano » Sat Feb 17, 2024 9:21 am

Or this?

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: function urlLoad( cUrl )

Postby Otto » Sat Feb 17, 2024 11:18 am

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.

viewtopic.php?f=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
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: function urlLoad( cUrl )

Postby Enrico Maria Giordano » Sat Feb 17, 2024 11:24 am

I don't like it. It requires a 4 MB DLL! Or am I wrong?
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: function urlLoad( cUrl )

Postby nageswaragunupudi » Sat Feb 17, 2024 12:01 pm

With Image URL
Image
Regards

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

Re: function urlLoad( cUrl )

Postby Enrico Maria Giordano » Sat Feb 17, 2024 12:07 pm

There are many ways to skin the cat. :-)
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: function urlLoad( cUrl )

Postby nageswaragunupudi » Sat Feb 17, 2024 1:19 pm

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
nageswaragunupudi
 
Posts: 10642
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: function urlLoad( cUrl )

Postby karinha » Sat Feb 17, 2024 1:21 pm

Enrico Maria Giordano wrote:Or this?

Code: Select all  Expand view
#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 view

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
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: function urlLoad( cUrl )

Postby Enrico Maria Giordano » Sat Feb 17, 2024 2:06 pm

You have to link wininet.lib from your C compiler.
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: function urlLoad( cUrl )

Postby Enrico Maria Giordano » Sat Feb 17, 2024 2:09 pm

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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: function urlLoad( cUrl )

Postby Otto » Sat Feb 17, 2024 2:55 pm

Enrico, here how I use it with web:


viewtopic.php?f=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
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: function urlLoad( cUrl )

Postby Ruth » Sat Feb 17, 2024 4:45 pm

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.
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 71 guests