Search code examples
javascripthttpgoogle-apps-scriptseopagerank

How to get Google PR by HTTP request in Google Apps Script?


I'm working on Spreadsheet that contains list of sites and rates them. Part of rating algorithm is Google PageRank. Now I don't know how to create a request to get PR, rather I don't know on which URL send request. Can you help me? Thank you in advance.


Solution

  • Check out my repository hosted at GitHub for a suitable script in PHP. Below is an example for Google Apps Script in combination with the mentioned script on GitHub.

    function getPageRank() {
      // Generate a log, then email it to the person who ran the script.
      var response = UrlFetchApp.fetch("http://cdn.florianbussmann.de/github/pagerank/script.php");
      Logger.log(response.getContentText());
      var recipient = Session.getActiveUser().getEmail();
      var subject = 'Fetched PageRank';
      var body = Logger.getLog();
      MailApp.sendEmail(recipient, subject, body);
    }
    

    Feel free to ask further questions.