Coder Social home page Coder Social logo

macrodownload's Introduction

macro-execution

This is a simple plug-in based on puppeteer.

Currently it supports macro download. It helps monitoring tasks status for macro downloading files from a virtual web page.
It also provides customized settings and pushes download progress for per task.

Please feel free to use it in javascript or typescript projects.

Install

  • npm install macro-execution

Usage

Used in js projects:

let me = require(`macro-execution`); 

function A(tasks){
  let test = new me.MacroDownload();
  return test.download(tasks, {site: 'localhost:3000'})
      .then(test.close);
}

let tasks = [{
  name: 'test link',       // task name
  menuList: [],            // nested menu wait to be clicked
  downloadPath: './Test',  // the directory to download files
  downloadLink: [],        // download link set, e.g.
                           // linkInfo {
                           //       name: ''
                           //       waitSelector: ''    // selector for download body
                           //       errorSelector: ''   // selector for possible error
                           //       downloadLink: ''    // selector for download link
                           //   }
  macroId: 'q1'            // unique id for running tasks
}];

A(tasks);

Used in ts projects:

import {Task, MacroDownload} from 'macro-execution';

export function A(tasks: Task[]): Promise<void> {
    let test = new MacroDownload();
    return test.download(tasks, {site: 'http://localhost:3000'})
        .then(test.close);
}

Launch options

Parameters default Value Descriptions
site -- must be set: site to visit

API

  • Disconnect
test.close();  
  • Monitoring task status
test.runningSteam.subscribe(list => {  

// do something with ${list}  

// [{  "name":"test link",  
//     "processInfo": {"pid":25459,"cpu":0},   // process id and cpu info  
//     "macroId":"q1",                         // unique id for running tasks  
//     "total":0,                              // total number for per task   
//     "success":0,                            // current success number for per task   
//     "errInfo":[],                           // error message  
//     "otherErr":[]                           // unexpected error message collection   
// }]   
});  

Coming soon

More supports is coming...

It's for open source learning.
Any questions please feel free to contact me.

macrodownload's People

Contributors

jeanzhao avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.