ContentMine / quickscrape

A scraping command line tool for the modern web
MIT License
259 stars 42 forks source link

Relative path for scraper definition resolved to wrong location #56

Open dan2097 opened 9 years ago

dan2097 commented 9 years ago

When using the example command i.e. quickscrape \ --url https://peerj.com/articles/384 \ --scraper journal-scrapers/scrapers/peerj.json \ --output peerj-384 --outformat bibjson

I encountered an issue where the scaper was instead resolved to: /home/workshop/peerj-384/journal-scrapers/scrapers/peerj.json (instead of /home/workshop/journal-scrapers/scrapers/peerj.json)

This was reported as a failure at this line program.scraperdir = path.resolve(program.scraperdir);

I believe the issue is caused by the following line which changes the working directory to the output directory: process.chdir(program.output); tld = process.cwd();

Moving these two lines till after all absolute paths are determined fixed the problem for me.