FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Google search
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Google search
Posted: Thu Mar 23, 2023 06:21 PM
http://fivewin.com.br/index.php?/topic/36548-google-search/

Feito Sandor. Obrigado.
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\GOOGLEBU.PRG - MODIFICADO EM: 23/03/2023 - Joao Santos.

#include "FiveWin.ch"

// The example loads the Google search page and enters "xHarbour" as
// query data. The response from Google for the query is stored in a local
// HTML file.

PROCEDURE Main

   LOCAL oHttp, cHtml, hQuery, cFile

   oHttp := TIpClientHttp():new( "http://www.google.de/search" )

   // build the Google query
   hQUery := Hash()
   hSetCaseMatch( hQuery, .F. )

   hQuery[ "q" ]    := "xHarbour"
   hQuery[ "hl" ]   := "en"
   hQuery[ "btnG" ] := "Google+Search"

   /*
   hQuery[ "q" ]    := "FiveWin"
   hQuery[ "hl" ]   := "en"
   hQuery[ "btnG" ] := "Google+Search"
   */

   // add query data to the TUrl object
   oHttp:oUrl:addGetForm( hQuery )

   // Connect to the HTTP server
   IF oHttp:open()

      // downlowad the Google response
      // cHtml := oHttp:readAll()

      // http://fivewin.com.br/index.php?/topic/36548-google-search/

      /*
      Fala Kapi...  Faz tempo que não 'posto' por aqui mas vai lá...

      Não sei onde achou isso, mas é interessante.

      Uma pequena alteração: troque alinha:

      cHtml := oHttp:readAll()    //  Kapi

      por:
      */

      cHtml := strtran(oHttp:readAll(), "/images/br", "http://www.google.com/images/br")
      cHtml := strtran(cHtml, 'CsQyDc" href="', 'CsQyDc" href="http:\\www.google.com')

      /*
      Vai mostrar o ícone do GOOGLE e 'liberar' os links de  "VIDEOS", "IMAGES" e "NEWS"

      [ ]'s, Sandor
      */

      MemoWrit( "Google_xHarbour.html", cHtml )

      oHttp:close()

      // ? Len( cHtml ), "bytes Recebidos: "
      MsgInfo( Len( cHtml ), "bytes Recebidos: " )

      // ? "e Gravados Para o Arquivo: Google_xHarbour.html"
      MsgInfo( "e Gravados Para o Arquivo: Google_xHarbour.html", "Gravou em:" )

      ShellExecute( 0, "Open", "c:\fwh1905\samples\Google_xHarbour.html" )

   ELSE

      ? "Connection error:", oHttp:lastErrorMessage()

   ENDIF

RETURN NIL

// FIN - kapiabafwh@gmail.com
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Google search
Posted: Thu Mar 23, 2023 08:00 PM
many thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion