mercredi 31 juillet 2019

Can I use "request" and "cheerio" libraries to extract data from a .html file?

I'm creating a React Web Application and using request and cheerio to do some Web Scrapping. I need to extract data from a .html file. The user enters with a .html in an input:

<input type='file' />

How can I extract data from the file? It is possible with those libraries? I know that request needs an url and I guess that it will be the local path to file. I used the following code to do Web Scrapping:

const foo = await new Promise(function (resolve, reject) {
    request.get(url, (err, res2, data) => {
        const $ = cheerio.load(data)
        let s = $("tbody < table.table_lt").text().replace(/\t/g, '').replace(/\n/g, '')
        resolve(s)
    })  
})

But this work just with Web.




Aucun commentaire:

Enregistrer un commentaire