npm.io
1.0.5 • Published 3 years ago

cover-image-crawler

Licence
MIT
Version
1.0.5
Deps
5
Size
6 kB
Vulns
3
Weekly
0

cover-image-crawler

npm package

NPM download Package Quality

Get the url of main image of page's using scraping in each IMG tag on the site and return the largest image found.

Usually it takes 1 second to return the result, if not found the return will be empty.

Installation

npm install cover-image-crawler

Use example

const imageCrawler = require('cover-image-crawler');

imageCrawler.capture('https://www.diariodepernambuco.com.br/noticia/viver/2019/07/vintage-culture-e-mais-cinco-atracoes-em-festival-eletronico-no-recife.html', function(err, image_url){
  if(!err){
    console.log(image_url);
  }
})

Use example - Async/Await

const imageCrawler = require('cover-image-crawler');

async function test(){
    
    let teste =  await imageCrawler.capture('https://www.bbc.com/news/world-us-canada-50863967');
    console.log(teste);
}
test()

Open to contributions and improvements

Newspaper sites working with accuracy

Work for future versions:

Ability options how: HTML tags to make the scraping (beyond <img)

Keywords