Hello, visionjinx and Jerome!
Thank you very much for your suggestion!
And sorry for mycvague query.
The thing I want to do is to search only a single character, but to
search the string that includes (some) special character(s).
For example, I want to search the string "7% solution" which means
"seven percent solution".
If you input special characters like "%" (percent signs) to Google
search, Google will ignore the special character.
In the example above, the engine will return the same result as if you
saught "7 solutions".
In the book GOOGLE HACKS version 2 published by O'Reilly, you could
make it with Google Search API with SOAP.
But I'm afraid that you cannot make it with Google AJAX Search API
anymore.
Thanks to Jerome, I had revised my code as below.
But it seems that you will get the same result no matter if you pass
Google "50%" or "50".
Google seems to ignore the percent sign and just search the number 50.
This is the same result if you use the usual Google Web search.
If you try this three searches;
50%
50%25
50
The result will be all the same: Google searches just the number 50.
I hope I could ask you what I mean.
Do you have any other Idea?
Thank you very much!!!
#! perl
# gSearch.pl
#
use strict;
use warnings;
use LWP::Simple;
use JSON::Syck;
#first -- search "50"
#my $response = get("http://ajax.googleapis.com/ajax/services/search/
web?v=1.0&rsz=large&hl=ja&q=".urlencode("50"));
#second -- search "50"
my $response = get("http://ajax.googleapis.com/ajax/services/search/
web?v=1.0&rsz=large&hl=ja&q=".urlencode("50%"));
warn urlencode("50%");
my $data = JSON::Syck::Load($response);
foreach (@{$data->{responseData}{results}}){
print "-----------------","\n";
print "GsearchResultClass",$_->{GsearchResultClass},"\n";
print "unescapedUrl:",$_->{unescapedUrl},"\n";
print "url:",$_->{url},"\n";
print "visibleUrl:",$_->{visibleUrl},"\n";
print "cacheUrl:",$_->{cacheUrl},"\n";
print "title:",$_->{title},"\n";
print "titleNoFormatting:",$_->{titleNoFormatting},"\n";
print "content:",$_->{content},"\n";
}
sub urlencode{
my $a=shift;
$a=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
return $a;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en
-~----------~----~----~----~------~----~------~--~---