I am working on an application which gets the HTML from http://www.screener.in/.
I can enter a company name like "Atul Auto Ltd" and submit it and, from the next page, scrape the following details: "CMP/BV" and "CMP".
I am using this code:
require 'mechanize'
require 'rubygems'
require 'nokogiri'
Company_name='Atul Auto Ltd.'
agent = Mechanize.new
page = agent.get('http://www.screener.in/')
form = agent.page.forms[0]
print agent.page.forms[0].fields
agent.page.forms[0]["q"]=Company_name
button = agent.page.forms[0].button_with(:value => "Search Company")
pages=agent.submit(form, button)
puts pages.at('.//*[@id="top"]/div[3]/div/table/tbody/tr/td[11]')
# not getting any output.
The code is taking me to the right page but I am don't know how to query to get the required data.
I tried different things but was unsuccessful.
If possible, can someone point me towards a nice tutorial which explains how to scrape a particular class from an HTML page. The XPath of the first "CMP/BV" is:
//*[@id="top"]/div[3]/div/table/tbody/tr/td[11]
but it is not giving any output.