Skip to content
Cheerio for Google Apps Script
JavaScript
Branch: master
Clone or download
TANIGUCHI Masaya
TANIGUCHI Masaya Delete rollup.config.js
Latest commit 4838dc6 Sep 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist rollup (does't worked) Jun 15, 2018
src Use webpack Jun 15, 2018
.clasp.json Change the function exported Jun 14, 2018
.gitignore rollup (does't worked) Jun 15, 2018
README.md Add usage to readme Sep 5, 2018
appsscript.json rollup (does't worked) Jun 15, 2018
package-lock.json Use webpack Jun 15, 2018
package.json Use webpack Jun 15, 2018
webpack.config.js Use webpack Jun 15, 2018

README.md

cheerio for Google Apps Script

This project is unofficial update of https://github.com/3846masa/cheerio-gasify.

Difference to the project is follows.

Script ID: 1ReeQ6WO8kKNxoaA_O0XEQ589cIrRvEBA9qcWpNqdOP17i47u6N9M5Xh0

Adding the library to your project

Cheerio (cheeriogs) for Google Apps Script is made available as a script library. This is how you add it to your project:

Select "Resources" > "Libraries..." in the Google Apps Script editor. Enter the project key (1ReeQ6WO8kKNxoaA_O0XEQ589cIrRvEBA9qcWpNqdOP17i47u6N9M5Xh0) in the "Find a Library" field, and choose "Select". (If you have copied the library, enter instead the project key of your copy.) Select the highest version number, and choose Cheerio as the identifier. (Do not turn on Development Mode unless you know what you are doing. The development version may not work.) Press Save. You can now use the Cheerio (cheeriogs) library in your code.

Usage

Returns the content of Wikipedia's Main Page

  const content = getContent_('https://en.wikipedia.org');
  const $ = Cheerio.load(content);
  Logger.log($('#mp-right').text());

Returns the content of the first paragraph <p> of Wikipedia's Main Page

  const content = getContent_('https://en.wikipedia.org');
  const $ = Cheerio.load(content);
  Logger.log($('p').first().text());

Changes the content of the gas server part before hosting. !Do not do this. But you can.

  const html = HtmlService.createHtmlOutputFromFile("index").getContent();
  const $ = Cheerio.load(html);
  $("#main").append("<p>Cheeriosse!!1</p>");
  return HtmlService.createHtmlOutput(
    Utilities.formatString("<html>%s</html>", $('html').html())
  );
You can’t perform that action at this time.