Sunday 15 May 2011

node.js - In JavaScript, How can I access properties of children nodes? -


I am creating a link scraper in CasperJS, and the main functions look like this:

  function findLinks () {back array.protitip.map.col (document.querySelectorAll ('a'), function (e) {return {href: e.href, title: e.title, rel: e. Rel, anchor: e.text, innerHTML: e.inner HTML};}); }   

However, I would like to modify the findLinks () in such a way that if my link scapper finds something like this:

& lt; A href = "#" headline = "anchor tag" rel = "nofollow" & gt; & Lt; Img src = "myimage.jpg" alt = "beautiful image" /> gt; & Lt; / A & gt;

I personally use & lt; Img & gt; I can use the attributes, as soon as I do with the link

I am reading Mozilla MDN, and CasperJes and I have not found any way to achieve it yet, / P>

Any help would be greatly appreciated!

You

collecting children Returning the child element of the given element

HTML in your example:

  var b = document.querySelectorAll ('a') [0]; Warning (b.children [0] .src); // Source of the first hair: myimage.jpg   



No comments:

Post a Comment