ruby - I'm trying to extract each a href link on an html page for evaluation w/ nokogiri and xpath -


I am trying to extract every a href link on html page for html / nokogiri and xpath on html page. I have just seen the page titles just dragging out. I'm not interested in the link title, but it is pointing to that URL.

Here's what I have:

  doc = Nokogiri :: HTML (open ("http://www.cnn.com")) doc.xpath (' / /a').each do | Node | Does node.text put an end  

Can someone guide me to fix this thing that I'm pulling the actual href instead of the text?

Your XPATH // is pulling back all the elements that contain text content to access the attributes You can use @attrname for example

  // a / href  

You will get a href of the document


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -