Search code examples
htmlgoogle-apps-scriptgoogle-appsgoogle-docs-apigoogle-sheets-api

Google App script extracting data from website


So I am writing a script which look at review done on google+ pages and updates a google spreadsheet.

I have found out that the line in the html which holds this value is

<span class="A7a">103</span> 

I just need to make it possible for me to extract from the page with just knowing the URL and that html code.


Solution

  • Use

    var response = UrlFetchApp.fetch("http://www.website.com/");
    

    To fetch the html of the page. Then use something like

    var cut = response.substring( str.indexOf( "<span class="A7a">" ), response.length);
    var value = cut.substring(0, cut.indexOf("</span>"));
    

    https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String)