Forum: Ruby tag and attribute in Nokogiri

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">
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.