Passing arguments to evaluatePage()
Created by: arthurakay
What is the current behavior?
async _scrape() {
if (!this._options.evaluatePage) return null;
await this._addJQuery();
return this._page.evaluate(this._options.evaluatePage);
}
See the Puppeteer docs -- evaluatePage()
can be passed arguments.
headless-chrome-crawler
does not allow me to pass arguments to the function.
What is the motivation / use case for changing the behavior?
It would be nice to have access to variables from outside of the page context; e.g., if I needed code to eval
in the page context.
Solution could be something like the following:
async _scrape() {
if (!this._options.evaluatePage) return null;
await this._addJQuery();
return this._page.evaluate(this._options.evaluatePage, this._options.evaluatePageArguments);
}
I can issue a pull request for this (including some updates to the documentation), but I wanted to ask if this would even be considered/accepted first.