IonicaBizau / scrape-it

🔮 A Node.js scraper for humans.

Home Page:http://ionicabizau.net/blog/30-how-to-write-a-web-scraper-in-node-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How get table heading/Column name

sklyerking opened this issue · comments

My Code :
var parm = {
heading : {
selector : ".wikitable tr",
data : {
headin_name: "th"
}
}
};

var url= "https://en.wikipedia.org/wiki/List_of_Prime_Ministers_of_India"
scrapeIt(url, parm ).then(({ data, response }) => {
console.log(data);
})

CURRENT OUTPUT : { heading: { headin_name: '№\nName(birth–death)\nPortrait\nParty(Alliance)\nElected constituency\nTerm of office[6]\nAppointed by\nLok Sabha[a]\n1\n–\n2\n–\n3\n4\n5\n(3)\n6\n7\n8\n9\n10\n11\n12\n(10)\n13\n14' } }

But I want output like :
{ heading :{ headin_name : { No, Name(birth–death) , ..... } } }

Please ask questions on Stackoverflow.