The source presented in the browser does not necessarily match the request of the HTML file itself, because Ajax is used to load fragments of pages after the initial, requested page load.
You cannot use conventional methods to extract the source of a page if it uses JavaScript and Ajax, unless you decode the entire content chain and re-create them in your Ruby code.
Or you can use a browser that Ruby can talk to, tell it to load the start page, which will then lead to JavaScript actions in the browser, the browser will load additional content, then your code will be able to extract it and do what you want. To do this, you should look at Watir or one of its derivatives.
source share