开发者

Suggestions on how to access google webmaster tools' api through R?

开发者 https://www.devze.com 2023-01-20 10:37 出处:网络
I wish to access my Google Webmaster\'s tools\' API via R. I see from here: http://code.google.com/apis/w开发者_Python百科ebmastertools/docs/2.0/reference.html

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

I see from here:

http://code.google.com/apis/w开发者_Python百科ebmastertools/docs/2.0/reference.html

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

Any suggestions on how to do it?


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


I guess you could use the Java client with rJava.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号