Solved

c# google search

Posted on 2011-02-15
3
751 Views
Last Modified: 2012-06-21
I get this code in internet and it show
I have this file wsdl.exe on C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin



Error      1      The type or namespace name 'GoogleSearchService' could not be found (are you missing a using directive or an assembly reference?)      C:\Users\¿¿¿7\AppData\Local\Temporary Projects\googlesearch\Program.cs      22      9      googlesearch



// googly.cs
// A Google Web API C# console application.
// Usage: googly.exe <query>
// Copyright (c) 2002, Chris Sells.
// No warranties extended. Use at your own risk.
using System;
class Googly
{
    static void Main(string[] args)
    {
        // Your Google API developer's key.
        string googleKey = "insert key here";
        // Take the query from the command line.
        if (args.Length != 1)
        {
            Console.WriteLine("Usage: google.exe <query>");
            return;
        }
        string query = args[0];
        // Create a Google SOAP client proxy, generated by:
        // c:\> wsdl.exe http://api.google.com/GoogleSearch.wsdl
        GoogleSearchService googleSearch = new GoogleSearchService();
        // Query Google.
        GoogleSearchResult results = googleSearch.doGoogleSearch(googleKey,
    query, 0, 10, false, "", false, "", "latin1", "latin1");
        // No results?
        if (results.resultElements == null) return;
        // Loop through results.
        foreach (ResultElement result in results.resultElements)
        {
            Console.WriteLine();
            Console.WriteLine(result.title);
            Console.WriteLine(result.URL);
            Console.WriteLine(result.snippet);
            Console.WriteLine();
        }
    }
}

Open in new window

0
Comment
Question by:teera
3 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 167 total points
ID: 34904387
0
 
LVL 8

Assisted Solution

by:guvera
guvera earned 166 total points
ID: 34904567
Hi,

There might be two possible causes for this error.

  1. May be you have not created your "net" folder" as web application.
  2. May be you have named the namespace wrong while creating the assembly.

Also please check the below links.

 http://www.sitepoint.com/forums/showthread.php?t=388702

Hope it may helpful to you.

Regards
Guvera
0
 
LVL 15

Assisted Solution

by:Russell_Venable
Russell_Venable earned 167 total points
ID: 34913043
knowing that Googles WSDL interface code is obsolete and how Google has switched to using JSON and AJAX requests as they allow your searches to be quicker. Checking the SOAP proxy address to see if google is still implementing it, you would notice that manually browsing to the address show's.
 Google 404So in otherwords you need to use the current API given by Google to access there functionality.
You will need to sign-up for a API key if you dont already have one:Google API Key Registration

After gaining the key you can download the Current API for clients from here:
Google Data Protocol  - Client Libraries

Just add the required userspace:
using Google.GData.Client;

Open in new window

and then then convert your code from there or
 Best solution I can give you is using Gapi.NET - .NET (C#) wrapper for Google AJAX API as this is the method currently implemented to use googles search results and this wrapper is the solution for using those JSON/AJAX posts.


Reference:
Google SOAP Search API (No Longer Available)
This is another example but using googles query and regex to filter content.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question