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

后端 未结 8 1841
清歌不尽
清歌不尽 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:23

    I made cheeriogs for your problem. it's works on GAS as cheerio which is jQuery-like api. You can do that like this.

    const content = UrlFetchApp.fetch('https://example.co/').getContentText();
    const $ = Cheerio.load(content);
    Logger.log($('p .blah').first().text()); // blah blah blah ...
    

    See also https://github.com/asciian/cheeriogs

提交回复
热议问题