How to search the web with Google Search API without limit - c#

I need a web search be my app and it would be fine to use google web search for.
This works in different cases when I do the code by myself or use assemblies like GAPI.
The problem is that I ever get an error because of paging the results:
ResponseStatus: 400, Reason: out of range start
About this problem I found this by the GAPI developer:
Google AJAX Search API does not allow more than 64 results (e.g. max page is 56).
But I need more results as this is to less for my usage I need at least 500...
Is there another way to get more result by searching the web?

It looks like GAPI is using the old Google Search API which has been officially deprecated as of November 1, 2010.
If you want more results you should look into another library or implementing your own using the Google Custom Search API:
https://developers.google.com/custom-search/v1/overview

Related

Configuring GSA(Google Search Appliance) in ASP.NET MVC Application

I am using GSA for my application.I want to display promoted results as part of my application.Can any one suggest me in which way i can use OneBox for the getting promotted results.In which way i can configure it in GSA Admin Console?What type of results i will get on application from the service?
Have you looked at keymatches? That's how you normally handle promoted results with the GSA.

Is there a C# API that can aid in building Google Maps links?

For example:
OpenUrl(GoogleMaps.Location("my address here"));
Would open up Google Maps and input the address as if it were typed right into the search bar on Google Maps itself.
Even better if it was able to do something like:
OpenUrl(GoogleMaps.Directions("Starting address", "End Address"));
I don't want Google Maps embedded into my application or anything fancy like that. Url generation would be perfect for my needs.
Any ideas?
May be you are looking for:
Google Maps API for .NET
For Url generation use:
Getting a static map url
Static Maps support allows you to get a valid url which you can use,
for example, with an tag.
If you are using NuGet in Visual Studio, use http://nuget.org/packages/GoogleMapsApi

accessing websites using C#

I have a problem here. Assume there's a basic calculator implemented in javascript hosted on a website ( I have googled it and to find an example and found this one: http://www.unitsconverter.net/calculator/ ). What I want to do is make a program that opens this website, enters some value and gets the return value. So, in our website calculator, the program:
- open the website
- enters an operand
- enters an operation
- enters an operand
- retrieve the result
Note: things should be done without the need to show anything to the user ( the browser for example ).
I did some search and found about HttpWebRequest and HttpWebRespond. But I think those can be used to post data to the server, which means, The file I'm sending data to must be php, aspx or jsp. But Javascript is client side. So, I think they are kind of useless to me in this case.
Any help?
Update:
I have managed to develop the web bot using WebBrowser Control tool ( found in System.Windows.Forms )
Here's a sample of the code:
webBrowser1.Navigate("LinkOfTheSiteYouWant"); // this will load the page specified in the string. You can add webBrowser1.ScriptErrorsSuppressed = true; to disable the script in a page
webBrowser1.Document.GetElementById("ElementId").SetAttribute("HTMLattrbute", "valueToBeSet");
Those are the main methods I have used to do what I wanted to.
I have found this video useful: http://www.youtube.com/watch?v=5P2KvFN_aLY
I guess you could use something like WatiN to pipe the user's input/output from your app to the website and return the results, but as another commenter pointed out, the value of this sort of thing when you could just write your own calculator fairly escapes me.
You'll need a JavaScript interpreter (engine) to parse all the JavaScript code on the page.
https://www.google.com/search?q=c%23+javascript+engine
What you're looking for is something more akin to a web service. The page you provided doesn't seem like it accepts any data in an HTTP POST and doesn't have any meaningful information in the source that you could scrape. If for example you wanted to programmatically make searches for eBay auctions, you could figure out how to correctly post data to it eg:
http://www.ebay.com/sch/i.html?_nkw=http+for+dummies&_sacat=267&_odkw=http+for+dummies&_osacat=0
and then look through the http response for the information you're looking for. You'd probably need to create a regular expression to match the markup you're looking for like if you wanted to know how many results, you'd search the http response for this bit of markup:
<div class="alt w"><div class="cnt">Your search returned <b>0 items.</b></div></div>
As far as clientside/javascript stuff, you just plain aren't going to be able to do anything like what you're going for.
It is a matter of API: "Does the remote website expose any API for the required functionality?".
Well web resources that expose interactive API are called web service. There are tons of examples (Google Maps for istance).
You can access the API -depending on the Terms & Conditions of the service- through a client. The nature of the client depends on the kind of web service you are accessing.
A SOAP based service is based on SOAP protocol.
A REST based service is based on REST principles.
So, if there is an accessible web service called "Calculator", then you can access the service and, for istance, invoke the sum method.
In your example, the calculator is a Javascript implementation, so it is not a web service and it cannot be accessed via HTTP requests. Though, its implementation is still accessible: it is the javascript file where the calculator is implemented. You can always include the file in your website and access its functions via javascript (always mind terms and conditions!!).
A very common example is the jQuery library stored in Google Libraries.

How to detect crawlers in Asp.net MVC

I'm using an action filter that checks what browser version is being used on my site, if it's an older browser I put up a div at the top asking them to upgrade. I don't want web crawlers to get the div message, so I've implemented HttpBrowserCapabilitiesBase.Crawler and it looks like it works for Google, but Bing and the others don't seem to register as crawlers. Strange for a Microsoft product to not notice Bing as a crawler!
Is there some way to add user agents to the crawler property or something?
Thanks!
Edited: I'm using asp.net mvc 3, it looks like I need to user .Browser files(?). Anyone know of a comprehensive set of .Browser files out there for Bing and the rest of the crawlers?
You will probably need to update your browscap.ini file as the one shipped with IIS is probably old. You can get a new one at one of the following URLs:
http://browsers.garykeith.com/downloads.asp
http://owenbrady.net/browsercaps/
browscap.ini usually lives at: c:\windows\system32\inetsrv\browscap.ini
We're not using MVC but we do this:
Regex.IsMatch(Request.UserAgent, #"bot|crawler|baiduspider|80legs|ia_archiver|voyager|curl|wget|yahoo! slurp|mediapartners-google", RegexOptions.IgnoreCase);
More options in my answer here:
Detecting honest web crawlers

Programmatically get the number of indexed pages in Google?

As an SEO metric I'd like to programmatically get the number of by Google indexed pages.
(if I search "site:mydomain.com" I want the get number of pages found).
Is there any lib for this or do I need to parse a google request?
you should use Google Webmaster Tool API.
First login in google webmaster with gmail account and familiar with the functionality then see following developer guide:
http://code.google.com/apis/webmastertools/docs/2.0/developers_guide.html
Here's something I put together that will work for a few queries per IP address per hour:
public static Int32 GooglePages(string sourceDomain)
{
String googleSource
= (new WebClient()).DownloadString(
#"http://www.google.com/search?q=site%3A" + sourceDomain);
return Convert.ToInt32(
Regex.Match(googleSource,
#"about \<b\>([0-9,]*)\<\/b\> from ")
.Groups[1].Value.Replace(",", ""));
}
If you are going to use it often, or make many queries on a regular basis I would recommend using an officially sanctioned API.
Has your site been setup in Google Analytics? If so you can use the Google Analytics API to get such information.
If you're interested in how to implement this in asp.net refer to this question.
There's probably a Google API you can use, rather than parsing the results of a search.

Categories

Resources