admin管理员组

文章数量:1410737

I'm trying to write a web crawler program using quickscrape, after I type

quickscrape \
  --url  \
  --scraper journal-scrapers/scrapers/peerj.json \
  --output peerj-384
  --outformat bibjson

and hit the "Enter" in my terminal, the library will generate the result from the crawler and put them into a folder.

Now I want to write a javascript progarm so that is will call these terminal mands for me, but I am not sure how to interact with terminal in node.js.

I'm trying to write a web crawler program using quickscrape, after I type

quickscrape \
  --url https://peerj./articles/384 \
  --scraper journal-scrapers/scrapers/peerj.json \
  --output peerj-384
  --outformat bibjson

and hit the "Enter" in my terminal, the library will generate the result from the crawler and put them into a folder.

Now I want to write a javascript progarm so that is will call these terminal mands for me, but I am not sure how to interact with terminal in node.js.

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Nov 5, 2016 at 16:28 DeidaraDeidara 6772 gold badges14 silver badges28 bronze badges 1
  • Possible duplicate of Execute and get the output of a shell mand in node.js – Damjan Pavlica Commented Jul 17, 2018 at 12:58
Add a ment  | 

1 Answer 1

Reset to default 7

I think child_process is that you need. https://nodejs/api/child_process.html

let exec = require('child_process').exec;
exec('quickscrape --url https://peerj./articles/384 --scraper journal-scrapers/scrapers/peerj.json --output peerj-384 --outformat bibjson', (error, stdout, stderr) => {
    //...
})

本文标签: javascriptrun terminal commands in node jsStack Overflow