How to parse an HTML string in Google Apps Script without using XmlService?

后端 未结 8 1856
清歌不尽
清歌不尽 2020-12-14 09:12

I want to create a scraper using Google Spreadsheets with Google Apps Script. I know it is possible and I have seen some tutorials and threads about it.

The main ide

8条回答
  •  别那么骄傲
    2020-12-14 09:25

    maybe not the cleanest approach, but simple string processing does the job too without xmlservice:

    var url = 'https://somewebsite.com/?q=00:11:22:33:44:55';
    var html = UrlFetchApp.fetch(url).getContentText();
    // we want only the link text displayed from here:
    //Ubiquiti Networks Inc.
    var string1 = html.split('')[0];           // all before ''
    var string3 = string2.split('>')[1];                   // all after '>'
    Logger.log('link text: '+string3);                     // string3 => "Ubiquiti Networks Inc."
    

提交回复
热议问题