Giter Club home page Giter Club logo

html-miner's People

Contributors

dependabot[bot] avatar marcomontalbano avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

html-miner's Issues

Question: How to get p and h3 without surrounding div

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!

Multiple selectors; title and href of links by css class?

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

  • select an element by a css selector (example .highlight--frontpage-title)
  • get it's text
  • get it's href

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.

Empty array with multiple sites

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.