0.0.9 • Published 1 year ago
grab-from v0.0.9
grab-from
Grab from using https. Or http.
And hey, as from 0.0.4 0.0.5 it actually works.
Ok, from 0.0.8 it actually works, and even follows redirection.
Usage
import grabFrom from 'grabfrom'
// grabbing from a site
const {binary, utf8, stream} = grabFrom('site.com')
// grab some files
const html = await utf8('/index.html')
const pic = await binary('/photo.jpg')
const clip = await stream('/movie.mp4')
// yes we do need to know what type to expect
Default is to use https. If http is needed then include that as the second parameter.
import grabFrom from 'grabfrom'
import http from 'node:http'
// use http
const {binary, utf8, stream} = grabFrom('site.com', http)
Default is also just to grab the response no matter what. If you care about errors then set the throw on error parameter to true:
import grabFrom from 'grabfrom'
import http from 'node:http'
// use http
const {binary, utf8, stream} = grabFrom('site.com', true)
// or
const {binary, utf8, stream} = grabFrom('site.com', http, true)