deanmao / node-chimera

A new kind of headless webkit integration for nodejs; a great alternative to phantomjs.
http://www.deanmao.com/2012/08/13/enter-chimera/
MIT License
847 stars 45 forks source link

Click each element then scrape #56

Closed Majed93 closed 8 years ago

Majed93 commented 8 years ago

Is there a way I could loop through each h2 element click it then scrape? This would be because the h2 elements are closed and it would be good to expand them to see the data and then extract the data. Since these elements don't already have click events, I assume this will need to somehow be hooked to it? But i'm not quite sure how to do this. I have had trouble previously with PhantomJS executing javascript like this before scraping because only PhantomJS 2.x was able to do what i required.

What i think the code might look like BUT where/how do i implement this for chimera to invoke?

` var selector = 'h2'; function (selector) { var els = $(selector); $.each(els, function (idx, el) { var event = document.createEvent('MouseEvent'); event.initEvent('click', true, true); el.dispatchEvent(event); });

    }, SELECTOR`