Forum: Ruby tag and attribute in Nokogiri

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
73700e119917433681f2e8f3e4369f74?d=identicon&s=25 Li CN (alex-osu3)
on 2016-09-09 15:19
Hi all,

Just a quick question: I want to extract some info from one webpage.
How do I return all <img> tag that contains id attribute that contains

Enclosed is one example for the format in my webpage and part of my

doc = Nokogiri::HTML(open(fn))

My script will return all <img> with id attribute. But I would like to
return the first 3 <img> ONLY.


<img alt="" src="" id="my_img8">
<img alt="" src="" id="my_img9">
<img alt="" src="" id="my_img10">

<img alt="" src="" id="img10">
<img alt="" src="" id="my">
This topic is locked and can not be replied to.