You can search for whatever you like if you encode the query string
correctly. If you're using Perl, you can roll your own simple
urlencode subroutine like this:
sub urlencode{
my $a=shift;
$a=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
return $a;
}
If you add that to your script, then the line of your that starts with
my $response = get( would look like this:
my $response =
get("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&hl=ja&q=
" . urlencode("string"));
Also, I notice that you have the hl parameter set to ja. Really, the
hl parameter does nothing for the search results; it primarily
determines the language you want to use in the user interface elements
of the Javascript side of the API. If you're wanting to restrict
results to Japanese only, you'll want to change that portion of the
line to lr=lang_ja, so you would end up with this:
my $response =
get("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&lr=lang_ja&q=
" . urlencode("string"));
Now, all of that said, as visionjinx pointed out, the API was not
really designed to search for single characters, so the results that
you receive may be a bit unpredictable. But if I'm not mistaken, in
Japanese, Chinese, etc., single characters can represent entire words.
I would think that Google would have accounted for at least some of
that in their search engine as well as the API.
Jeremy R. Geerdes
Effective website design & development
Des Moines, IA
For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]
Unless otherwise noted, any price quotes contained within this
communication are given in US dollars.
If you're in the Des Moines, IA, area, check out Debra Heights
Wesleyan Church!
And check out my blog, Adventures in Web Development, at
http://jgeerdes.blogspot.com
!
On Aug 30, 2009, at 3:39 AM, Vision Jinx wrote:
>
> Hello,
>
> As far as I know the AJAX APIs was not really set up for this so it is
> most likely not possible or not very reliable if so. (I don't think it
> was/is the primary purpose of the API)
>
> You can play around with some tests here though
> http://code.google.com/apis/ajax/playground/#hello_world
>
> I can try to follow up with some of the Google Devs on this in more
> detail but as far as I know its not really a viable solution for it.
>
> Cheers!
> Vision Jinx
>
> On Aug 30, 2:25 am, ohanami <[email protected]> wrote:
>> Hello!
>>
>> I'm a original poster that I had posted this topic.
>> I'm new to this group so I don't know whether you could see my topic.
>> Can you see it?
>> Do anybody know anything about it?
>> Thank you!
>>
>> On Aug 15, 3:18 pm, ohanami <[email protected]> wrote:
>>
>>> Hello!
>>
>>> I want to search special characters (for example parcent (%, 0x25)).
>>
>>> I read the O'Reilly's GOOGLE HACKS version 2 and I found that you
>>> could make it with Google Search API with SOAP in hack #75.
>>> But as you know, Google Search API with SOAP had been deprecated and
>>> the hack was also removed in the GOOGLE HACKS version 3.
>>
>>> I searched web and found that Google AJAX Search API is the new
>>> superset of Google Search API with SOAP.
>>> Can I search special characters (for example parcent (%, 0x25)) with
>>> it?
>>
>>> I don't know well about JavaScript so I searched and found a code
>>> written in Perl in the blog.
>>> This code uses this functionality:
>>> http://code.google.com/intl/en/apis/ajaxsearch/documentation/referenc
>>> ...
>>> and I could search the string special characters safely.
>>
>>> #! perl
>>> # gSearch.pl
>>> #
>>
>>> use strict;
>>> use warnings;
>>> use LWP::Simple;
>>> use JSON::Syck;
>>> my $response = get("http://ajax.googleapis.com/ajax/services/search/
>>> web?v=1.0&rsz=large&hl=ja&q=string");
>>> my $data = JSON::Syck::Load($response);
>>> foreach (@{$data->{responseData}{results}}){
>>> from_to($_->{title}, 'utf8' ,'shift-jis');
>>> from_to($_->{titleNoFormatting}, 'utf8' ,'shift-jis');
>>> from_to($_->{content}, 'utf8' ,'shift-jis');
>>> 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";
>>
>>> }
>>
>>> Can I make this code that can search special characters?
>>> Thank you very much in advance!
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---