Google App script extracting data from website

前端 未结 2 732
渐次进展
渐次进展 2021-01-14 16:16

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 val

相关标签:
2条回答
  • 2021-01-14 16:31

    I agree with the previous answer but there are some omissions

    var response = UrlFetchApp.fetch(url);
    var str = response.getContentText();
    var balise = '<span class="A7a">'
    var cut = str.substring(str.indexOf( balise ), response.length);
    var value = cut.substring(balise.length, cut.indexOf("</span>"));
    
    0 讨论(0)
  • 2021-01-14 16:34

    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)

    0 讨论(0)
提交回复
热议问题