Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/node
- const puppeteer = require('puppeteer');
- const args = process.argv.slice(2);
- const track_num = args[0];
- (async function main() {
- try {
- const browser = await puppeteer.launch();
- const [page] = await browser.pages();
- await page.goto("https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=" + track_num, { waitUntil: 'networkidle0' });
- const data = await page.evaluate(() => document.querySelector('.current-tracking-status-wrapper').textContent);
- // let info = data.replaceAll("\t","").replaceAll("\n","");
- let info = data.replaceAll("\t","");
- info = info.replaceAll("\n\n","");
- info = info.split("\n");
- info.reverse();
- for(i of info){
- console.log(i);
- }
- await browser.close();
- } catch (err) {
- console.error(err);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement