marcomontalbano / html-miner Goto Github PK
View Code? Open in Web Editor NEWA powerful miner that will scrape html pages for you. ` HTML Scraper ´
Home Page: https://marcomontalbano.github.io/html-miner
License: MIT License
A powerful miner that will scrape html pages for you. ` HTML Scraper ´
Home Page: https://marcomontalbano.github.io/html-miner
License: MIT License
Hi,
how do i get all the h3 and the following p without a surrounding div as an Object:
<div>
<div>
<h3>Text</h3>
<p>Text</p>
<h3>Text</h3>
<p>Text</p>
<h3>Text</h3>
<p>Text</p>
</div>
<div>
<h3>Text</h3>
<p>Text</p>
<h3>Text</h3>
<p>Text</p>
<h3>Text</h3>
<p>Text</p>
</div>
</div>
I was able to get both individual as arrays. Here is my successles Try:
let json = htmlMiner(html, {
myObject: {
_each_: 'div div',
_eachId_: function(arg) {
return arg.$scope.data('h3').replace(/\s/g, '');
}
h3: 'h3',
p: function(arg) {
return arg.$('h3 + p').text().trim();
}
}
console.log( json );
}
Thank you very much for your help!
Hey, @marcomontalbano
On one of the other issues, you suggested this to another user.:
htmlMiner(html, {
each: 'a',
text: function(arg) {
return arg.$scope.text();
},
href: function(arg) {
return arg.$scope.attr('href');
}
})
I want to do it a bit differently. I am scraping a news website and would like to
Can you help me please?
TY!
P.S.: The documentation of this project could use a bit of improvements. Once I fully understand it, might commit.
Hey!
I have the following code:
var sites = [
{
"url": "https://www.origo.hu/index.html",
"selector": "a.news-title",
"side": "right"
},
{
"url": "https://index.hu",
"selector": "h1.cikkcim a",
"side": "left"
}
]
for (site of sites) {
superagent
.get(site.url)
.end((err, res) => {
htmlMiner(res.text,{
_each_: site.selector,
text: function(arg) {
return arg.$scope.text();
},
href: function(arg) {
return arg.$scope.attr('href');
}
})
});
}
The parsing of one site does always work. But when using two sites, it returns the results from one site, and an empty array for the another site.
Why? I guess it doesn't parse it fast enough? How could I make it wait and then print the results?
Can you help me?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.