Extract search results from google

perl India
  • 17 years ago


    hi,


    I want some help regarding retrieving of the search results corresponding to a query from google.


    Thanks in ADVANCE

  • 17 years ago

    its easy. google provides an API for it.. u can just register at google and download the API as well as samples and work on it.. but it has a limit of 1000 searches per day.. so look out for it.. but i have devised another way for it..  
    what language r u using... if u can use RegExpressions then u can just get it without the help of API just tell what language r u using?

  • 17 years ago


    thanks AXE,


    I am using perl.

  • 17 years ago

    well perl supports reg expressions i suppose. u'll have to fine out that.
    heresz a VB code.
    let me explain what it does.
    u must have seen google pages? it has all the searched links in green color. i just get the info between the
    <font color=#008000> & </font> tags using regExperssion & lo v have the searched links...
    try the same in perl using any method. just look inside the font tag.. u'll get what u want. and without the Google API. so u can have unlimited searches!


    tell me if u have understood what i am trying to comvey.. i am bad at explaining..


    Code:

    Dim re As New RegExp
    Dim m As Match


    sLPattern = "<font color=#008000>"
    sRPattern = "</font>"


      re.pattern = "(<font color=#008000&gt([\w\W]*?)(" & sRPattern & ")"
      re.IgnoreCase = True
      re.Global = True
      For Each m In re.Execute(sData)
       sLink = LCase(m.value)
       sLink = Replace(sLink, sLPattern, "")
       Debug.Print sLink
       sLink = Replace(sLink, sRPattern, "")
       aSplitter = Split(sLink, " - ")
       If UBound(aSplitter) > 0 Then
           sHTTP = "http://" & aSplitter(LBound(aSplitter))
           sHTTP = "<a href ='" & sHTTP & "'>" & sHTTP & "</a>"
       End If
       If Duplicate Then
           SearchString = SearchString & sHTTP & "<br>"
           'gCol.Add sHTTP, sHTTP
       Else
           SearchString = SearchString & sHTTP & "<br>"
           'gCol.Add sHTTP
       End If
       
      Next



    regards

  • 17 years ago


    hi AXE,
           Thanks to u, but i work on linux platform.
         
            Any way i got how to do what i want. Thanks for the concern

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan