6

I wish to access my Google Webmaster's tools' API via R.

I see from here:

http://code.google.com/apis/webmastertools/docs/2.0/reference.html

That it requires fetching a feed behind https and parsing it.

Any suggestions on how to do it?

Josh
  • 10,961
  • 11
  • 65
  • 108
Tal Galili
  • 24,605
  • 44
  • 129
  • 187

3 Answers3

2

Based on some Googling, I'd say the RCurl library is your best bet for the HTTP stuff. They have a good example on how to do some basic operations and work with an XML payload: http://www.omegahat.org/RCurl/xmlParse.html

Like other GData services, the webmaster tools api is AtomPub-based XML. It should be fairly easy to parse using the XML library, but you'll need to code that yourself.

Googleanalytics4r mentioned by Brandon takes this same approach. See: https://github.com/sorenmacbeth/googleanalytics4r/blob/master/R/googleanalytics4r.R

Chris Sears
  • 6,502
  • 5
  • 32
  • 35
0

Its a bit hacky, but I access GWT data from R through the python tool here (http://code.google.com/p/webmaster-tools-downloads/source/browse/downloader.py), by issuing system() commands e.g.

feedback <- system("python ./gwt-tool/googlewebmastertool_download_gmt.py")

Where "feedback" will be the message's generated from the script, and the files appear in the working directory of the system call.

A better solution would be to use httr package to make the requests (which is a wrapper for RCurl suggested above) - I've found that httr smooths out some of the problems of configuration that RCurl can present.

Mark
  • 208
  • 2
  • 9
0

I guess you could use the Java client with rJava.

Matti Pastell
  • 9,135
  • 3
  • 37
  • 44
  • Hi Matti, could you be a bit more specific - I am not sure how to go about that. – Tal Galili Oct 14 '10 at 15:50
  • For the java side of things there are some examples http://code.google.com/intl/fi-FI/apis/webmastertools/docs/2.0/developers_guide_java.html, as how to call it from rJava I think you need to refer to its documentation. I'm not a Java programmer myself, but there a lot of projects that use rJava succesfully. – Matti Pastell Oct 14 '10 at 16:53
  • 1
    RGoogleData source might also give you some tips r-forge.r-project.org/projects/rgoogledata/ – Matti Pastell Oct 14 '10 at 17:41