Comments (6)
You are suppose to respect issue template when creating issue, the template exists for a reason. BTW stream example is documented here > https://github.com/sayem314/hooman#pipe-stream
from hooman.
Related issue you can read on to grasp more details: #3
from hooman.
Yeah sorry about that it's m'y first issue on github.
I dont understand what is the await lign for pipe can you help ?
from hooman.
@Clemv95 no problem then.
you can use it like this:
const fs = require('fs');
const request = require('request');
const emojis = require('./emojis.json');
const hooman = require('hooman');
const download = async function(uri, filename, callback) {
let file = fs.createWriteStream(filename);
let r = hooman.stream(uri).pipe(file);
r.on('error', function(err) {
console.log(err);
});
r.on('finish', function() {
file.close(callback);
});
};
hooman
.get(siteUrl)
.then((res) => {
for (let i = 0; i < emojis.length; i++) {
nom = emojis[i].image.slice(emojis[i].image.indexOf('emoji/') + 6, emojis[i].image.length);
download(emojis[i].image, './emojis/' + nom, function(err) {
console.log(err);
});
}
})
.catch((err) => {
console.log(err.message);
});
siteUrl
is the main base url of images where you will download images from. first you make dummy request to initialize cookie.
from hooman.
You can also use this function for image/small binary files.
const download = async function(uri, filename, callback) {
try {
const { body } = await hooman.get(uri, {
responseType: 'buffer',
});
// Write image to file
fs.writeFileSync('image.jpg', body);
console.log('Done');
} catch (err) {
callback(err);
}
};
from hooman.
Quick full example based your code:
const fs = require('fs');
const request = require('request');
const emojis = require('./emojis.json');
const hooman = require('hooman');
const download = async function(uri, filename, callback) {
try {
const { body } = await hooman.get(uri, {
responseType: 'buffer',
});
// Write image to file
fs.writeFileSync(filename, body);
callback();
} catch (err) {
callback(err);
}
};
for (let i = 0; i < emojis.length; i++) {
nom = emojis[i].image.slice(emojis[i].image.indexOf('emoji/') + 6, emojis[i].image.length);
download(emojis[i].image, './emojis/' + nom, function(err) {
console.log(err);
});
}
from hooman.
Related Issues (20)
- Cloudflare seem to change their technology HOT 1
- spamming with html content HOT 2
- Request returns 'Please enable javascript and reload the page' HOT 1
- Need some help if is posible HOT 4
- Fail to bypass cloudflare HOT 3
- Can't bypass CF Bot Fight Mode HOT 6
- Hooman can't bypass new challenge
- Am I doing something wrong? HOT 9
- Convert to typescript? HOT 1
- Hooman referer behaviour
- Captcha New Challenge HOT 7
- JS Challenge update HOT 1
- A suggestion HOT 3
- About update HOT 7
- Custom IM UNDER ATTACK mode support
- Not sure how to use this exactly... HOT 3
- Node >= v14 cause connect ECONNREFUSED 127.0.0.1:443 (eg: await hooman.get('https://www.malt.fr')) HOT 2
- No Longer Working HOT 4
- Can't retrieve HTML from some sites
- 403 response unhandled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hooman.