how to search the phrase of numbers

13 views
Skip to first unread message

Dina Z.

unread,
Nov 8, 2013, 8:54:14 PM11/8/13
to rubyonra...@googlegroups.com
Hi,Dear all,

I am trying to search the phrase of numbers in a html page in the
sentence below:

<div class="Results" id="yui_3_11_0_4_1383957936583_5009">(253
items)</div>

I used this piece of code, but it does not work,

limit= page.search("div[class=Results]").search("div").gsub("items","")

begin
Integer(limit)
rescue
return 0
end

Would you give me any suggestion on this?

Thank you,
Regards,
Di

--
Posted via http://www.ruby-forum.com/.

Tamara Temple

unread,
Nov 9, 2013, 5:57:17 PM11/9/13
to rubyonra...@googlegroups.com

On Nov 8, 2013, at 7:54 PM, Dina Z. <li...@ruby-forum.com> wrote:

> Hi,Dear all,
>
> I am trying to search the phrase of numbers in a html page in the
> sentence below:
>
> <div class="Results" id="yui_3_11_0_4_1383957936583_5009">(253
> items)</div>
>
> I used this piece of code, but it does not work,
>
> limit= page.search("div[class=Results]").search("div").gsub("items","")
>
> begin
> Integer(limit)
> rescue
> return 0
> end
>
> Would you give me any suggestion on this?

Break apart the chain of method calls above, and see what each is returning.
Reply all
Reply to author
Forward
0 new messages