Solved

c# google search

Posted on 2011-02-15
3
747 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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