Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Last active April 25, 2020 07:17
Show Gist options
  • Select an option

  • Save adamculpepper/88f3d973672705c4d09ef81767932340 to your computer and use it in GitHub Desktop.

Select an option

Save adamculpepper/88f3d973672705c4d09ef81767932340 to your computer and use it in GitHub Desktop.

Revisions

  1. adamculpepper revised this gist Apr 25, 2020. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions puppeteer-read-txt.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    const puppeteer = require('puppeteer');
    const fs = require('fs');

    var contentHtml = fs.readFileSync('file.txt', 'utf8');
    await page.setContent(contentHtml);
    console.log(contentHtml);
    var fileContent = fs.readFileSync('file.txt', 'utf8');
    console.log(fileContent);
  2. adamculpepper revised this gist Apr 25, 2020. 2 changed files with 9 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions puppeteer-read-json.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,8 @@ const fs = require('fs');
    const util = require('util');

    // data
    const rawdata = fs.readFileSync('plates.txt');
    const rawdata = fs.readFileSync('plates.json');
    const textDecoder = new util.TextDecoder('utf-8');
    const stringData = textDecoder.decode(rawdata);
    const objects = JSON.parse(stringData);
    const objects = JSON.parse(stringData);
    console.log(objects);
    6 changes: 6 additions & 0 deletions puppeteer-read-txt.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    const puppeteer = require('puppeteer');
    const fs = require('fs');

    var contentHtml = fs.readFileSync('file.txt', 'utf8');
    await page.setContent(contentHtml);
    console.log(contentHtml);
  3. adamculpepper renamed this gist Apr 25, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. adamculpepper created this gist Apr 25, 2020.
    9 changes: 9 additions & 0 deletions puppeteer-read-json,js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    const puppeteer = require('puppeteer');
    const fs = require('fs');
    const util = require('util');

    // data
    const rawdata = fs.readFileSync('plates.txt');
    const textDecoder = new util.TextDecoder('utf-8');
    const stringData = textDecoder.decode(rawdata);
    const objects = JSON.parse(stringData);