You can get the number by scanning with a regular expression that matches the numbers:
page.css('body').text.scan(/\d+/)
page.css('body').text.scan(/\d+/).first.to_i
scanreturns an array with all matches. If the document has several numbers, simply select the item you want to select:
page.css('body').text.scan(/\d+/)
page.css('body').text.scan(/\d+/)[1].to_i
source
share