Jump to content
Fivewin Brasil

Google search


kapiaba

Recommended Posts

// C:\FWH\SAMPLES\GOOGLEBU.PRG
	#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()
	      MemoWrit( "Google_xHarbour.html", cHtml )
	      oHttp:close()
	      ? Len( cHtml ), "bytes Recebidos: "
	      ? "e Gravados Para o Arquivo: Google_xHarbour.html"
	      ShellExecute( 0, "Open", "c:\fwh1905\samples\Google_xHarbour.html" )
	   ELSE
	      ? "Connection error:", oHttp:lastErrorMessage()
	   ENDIF
	RETURN NIL
	// FIN

Regards, saludos.

Link to comment
Share on other sites

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 

 

Link to comment
Share on other sites

Feito Sandor. Obrigado.

// 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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...