Results 1 to 1 of 1

Thread: tool to get suggested searches

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    159

    tool to get suggested searches

    I'm trying to figure out how to create a simple program that will take a keyword / search term in Google and give me back the suggested terms that pop down from Goolge's search box.

    I've got to figure out how to scrape the data from this page:

    http://google.com/complete/search?output=toolbar&q=

    The keyword would go after the &q= and then the results would be spit out in an xml file. I have no experience in scraping tools so any advice would be much appreciated.

    Here is some scraper code I found and tried to modify but it's still not doing what I need it to do, any suggestions to remove the junk I don't need?

    VB Code Code:
    1. Imports System
    2. Imports System.Collections
    3. Imports System.ComponentModel
    4. Imports System.Data
    5. Imports System.Drawing
    6. Imports System.Web
    7. Imports System.IO
    8. Imports System.Net
    9. Imports System.Text.RegularExpressions
    10. Imports System.Text
    11. Imports System.Diagnostics
    12. Imports System.Runtime.Remoting.Services
    13. Public Class Form1
    14.  
    15.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    16.         MsgBox(getHipWS)
    17.     End Sub
    18.  
    19.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    20.  
    21.     End Sub
    22.     Public Function getHipWS() As String
    23.         Dim oSR As StreamReader = Nothing
    24.         Dim strURL As String = "http://google.com/complete/search?output=toolbar&q=" & TextBox1.Text.ToString
    25.         Dim objRequest As WebRequest = WebRequest.Create(strURL)
    26.         Dim objResponse As WebResponse = objRequest.GetResponse()
    27.         oSR = New StreamReader(objResponse.GetResponseStream())
    28.         Dim strContent As String = oSR.ReadToEnd()
    29.         Dim regex As New Regex("<toplevel>((.|" & vbLf & ")*?)</toplevel>", RegexOptions.IgnoreCase)
    30.         Dim oM As Match = regex.Match(strContent)
    31.         Return "<toplevel><CompleteSuggestion><suggestion data=" & oM.Value & "</CompleteSuggestion></toplevel>"
    32.     End Function
    33. End Class

    -Chris
    Last edited by cmmorris1; Jan 2nd, 2010 at 07:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width