Page 1 of 1

Retrieve Website Data

Posted: Tue Aug 04, 2015 9:05 pm
by cdmmaui
Hello Everyone,

Has anyone used FWH to create an application to "scrape" (retrieve) data from a website by providing a string parameter? If so, could you provide sample code?

Thank you,

Re: Retrieve Website Data

Posted: Wed Aug 05, 2015 8:03 am
by AntoninoP
Here some code from examples of harbour:

Code: Select all

proc main()
   local socket, buffer
   socket := hb_inetCreate()
   socket := hb_inetConnect( "www.fortify.net", 80, socket )
   ? "INETCONN", socket
   ? "INETTIMEOUT", hb_inetTimeout( socket, 500 )
   ? "INETERR", hb_inetErrorCode( socket )
   ? "INETFD", hb_inetFD( socket )
   ? "INETSEND", hb_inetSend( socket, "GET / http/1.1" + hb_inetCRLF() + "Host: " + "www.syenar.hu" + hb_inetCRLF() + hb_inetCRLF() )
   ? "INETERR", hb_inetErrorCode( socket )
   buffer := Space( 1024 )
   ? "INETRECVALL", hb_inetRecvAll( socket, @buffer, Len( buffer ) )
   ? "BUFFER", ">" + AllTrim( buffer ) + "<"
   ? "INETCLOSE", hb_inetClose( socket )
return
Hope this help,

Re: Retrieve Website Data

Posted: Wed Aug 05, 2015 8:15 am
by bpd2000
Thank you Mr. AntoninoP
For https sam code will work or any other method

Re: Retrieve Website Data

Posted: Wed Aug 05, 2015 8:25 am
by AntoninoP
The code is taken from harbour\contrib\hbssl\tests\test.prg, the same example show how to use ssl for a secure connection.
But I don't tried it, it is necessary download OpenSSL and build hbssl.
Regards,