Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export data from the evaluatePage() serialized data #134

Closed
maticrivo opened this issue Feb 25, 2018 · 2 comments
Closed

Export data from the evaluatePage() serialized data #134

maticrivo opened this issue Feb 25, 2018 · 2 comments

Comments

@maticrivo
Copy link

Can the exporter receive fields from the evaluatePage serialized data?

@yujiosaka
Copy link
Owner

yujiosaka commented Feb 25, 2018

@maticrivo
Here you go!

const HCCrawler = require('headless-chrome-crawler');
const CSVExporter = require('headless-chrome-crawler/exporter/csv');

const FILE = './tmp/result.csv';

const exporter = new CSVExporter({
  file: FILE,
  fields: ['response.url', 'result.title'],
});

HCCrawler.launch({
  evaluatePage: (() => {
    return { title: window.document.title }
  }),
  maxDepth: 2,
  exporter,
})
  .then(crawler => {
    crawler.queue('https://example.com/');
    crawler.onIdle()
      .then(() => crawler.close());
  });

result.xxx is what you are looking for.

@maticrivo
Copy link
Author

Thanks, for some reason it didn't work for me before, probably something wrong i was doing in the evaluatePage callback..
works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants