Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rp = require('request-promise');
- var fs = require('fs');
- module.exports = {
- downloadArchive: function (url) {
- var getStream = "";
- var options = { encoding: null, uri: url, method: 'GET' };
- rp(options).then(function(stream) {
- getStream = stream;
- WriteArchive(stream,".jpg");
- });
- return getStream;
- },
- WriteArchive: function (stream,ext) {
- try{
- fs.writeFileSync('./captcha'+ext, stream);
- }catch(e){
- console.log("Erro ao criar o arquivo" + e);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement