0

Am new to ruby. am trying to get the webpage contents and search and return a string from that response following code retunrs the webpage as html

require 'rubygems'
require 'uri'
require 'net/http'


AppArgs = Array.new

def get()
content = Net::HTTP.get('integration.twosmiles.com', '/status')
puts content
end

get()

html content

<!-- PAGE CONTENT -->
<div class="container-fluid page-content">
  <div class="row-fluid">
    <h1>Status</h1>
<p>The rails app is up.  Nothing to see here, move on.</p>
<br>
<p>uptime:</p>
 22:09:18 up 66 days, 22:37,  0 users,  load average: 0.00, 0.01, 0.05
<br>

<br><br>
<p>other</p>
# On branch deploy
<br>
commit bc1407b29697bab36bc2f5e35aa197228181e225
<br>

  </div>
</div>
<!-- END PAGE CONTENT -->

Above is the part of the web page content . From this content i want to get the commit bc1407b29697bab36bc2f5e35aa197228181e225 and ony want to return the key value bc1407b29697bab36bc2f5e35aa197228181e225.how it is possbile using ruby code

1
  • Try with nokigiri parsing gem. Commented Jun 17, 2014 at 5:29

1 Answer 1

1
key = get()[/commit\s+([a-f0-9]{10,})/i, 1]
puts key

Regex explanation here.

Sign up to request clarification or add additional context in comments.

1 Comment

can u please describe the meaning of this regular experssion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.