Hi, Can someone help as how to use R to program google search in the R code? I know that other languages can allow or have the google search API If someone can give me some links or sample code I would greatly appreciate. Thanks. -- Waverley @ Palo Alto
Hi: Do you mean something like> RSiteSearch('loess predict')[opens up a web page with 53 matches to the request] or package(sos) findFn('multiple imputation') ? If not, could you be more specific about what you're after? HTH, Dennis On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto < waverley.paloalto@gmail.com> wrote:> Hi, > > Can someone help as how to use R to program google search in the R > code? I know that other languages can allow or have the google search > API > > If someone can give me some links or sample code I would greatly > appreciate. > > Thanks. > > -- > Waverley @ Palo Alto > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
My question is how to use R to program google search. I found this information: "The SOAP Search API was created for developers and researchers interested in using Google Search as a resource in their applications." Unfortunately google no longer supports that. They are supporting the AJAX Search API. What about R? Thanks. On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto <waverley.paloalto at gmail.com> wrote:> Hi, > > Can someone help as how to use R to program google search in the R > code? ?I know that other languages can allow or have the google search > API > > If someone can give me some links or sample code I would greatly appreciate. > > Thanks. > > -- > Waverley @ Palo Alto >-- Waverley @ Palo Alto
Hi,
I have sent some request as how to embed the Google search API in R? I
remember on one mailing list people talked about this previously using
R.
I did some analysis on this and found that google API (SOAP based) has
retired and was replaced with the AJAX search API. I found the
following perl code which does the search using google AJAX API to
obtain the google search result? Has anyone know how to do the
equivalent in R? I am attaching the perl code as following:
Thanks much in advance.
#!/usr/bin/perl
# This example request includes an optional API key which you will need to
# remove or replace with your own key.
# Read more about why it's useful to have an API key.
# The request also includes the userip parameter which provides the end
# user's IP address. Doing so will help distinguish this legitimate
# server-side traffic from traffic which doesn't come from an end-user.
##
my $url =
"http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
. "q=Paris%20Hilton&key="get your own key from
google"&userip="your machine IP"";
# Load our modules
# Please note that you MUST have LWP::UserAgent and JSON installed to use this
# You can get both from CPAN.
use LWP::UserAgent;
use JSON;
# Initialize the UserAgent object and send the request.
# Notice that referer is set manually to a URL string.
my $ua = LWP::UserAgent->new();
$ua->default_header("HTTP_REFERER" => "your website");
my $body = $ua->get($url);
# process the json string
my $json = from_json($body->decoded_content);
# have some fun with the results
my $i = 0;
foreach my $result (@{$json->{responseData}->{results}}){
$i++;
print $i.". " . $result->{titleNoFormatting} . "(" .
$result->{url} . ")\n";
# etc....
}
if(!$i){
print "Sorry, but there were no results.\n";
}
On Fri, Sep 3, 2010 at 2:23 PM, Waverley @ Palo Alto
<waverley.paloalto at gmail.com> wrote:> Hi,
>
> Can someone help as how to use R to program google search in the R
> code? ?I know that other languages can allow or have the google search
> API
>
> If someone can give me some links or sample code I would greatly
appreciate.
>
> Thanks.
>
> --
> Waverley @ Palo Alto
>
--
Waverley @ Palo Alto