Skip to content

Commit

Permalink
Bump version 0.1.1, allow multiple pages
Browse files Browse the repository at this point in the history
  • Loading branch information
s0ph1e committed Jan 15, 2019
1 parent cfa4efb commit 44be729
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ const puppeteer = require('puppeteer');

class PuppeteerPlugin {
apply(registerAction) {
let browser, page;
let browser;

registerAction('beforeStart', async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
});

registerAction('afterResponse', async ({response}) => {
const contentType = response.headers['content-type'];
const isHtml = contentType && contentType.split(';')[0] === 'text/html';
if (isHtml) {
const url = response.request.href;

const page = await browser.newPage();
await page.goto(url);
return page.content();
const content = await page.content();
await page.close();
return content;
} else {
return response.body;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website-scraper-puppeteer",
"version": "0.1.0",
"version": "0.1.1",
"description": "Plugin for website-scraper which returns html for dynamic websites using puppeteer",
"readmeFilename": "README.md",
"main": "index.js",
Expand Down

2 comments on commit 44be729

@s0ph1e
Copy link
Member Author

@s0ph1e s0ph1e commented on 44be729 Mar 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SunnyGambino for suggestion. I'll consider adding cookies support to future release, created issue #2 for that

@s0ph1e
Copy link
Member Author

@s0ph1e s0ph1e commented on 44be729 Mar 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍
Feel free to create pull request @SunnyGambino

Please sign in to comment.