I used Nokogiri as below:
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML::Document for the page we’re interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=sparklemotion'))
But my bad,due to company firewall may be, I am getting error:
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `initialize': getaddrinfo: No such
host is known. (SocketError)
Thus I thought that I would use selenium-webdriver to navigate and nokogiri to work on webpage source html.
require "rubygems"
require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
driver.get "http://www.google.com/search?q=sparklemotion"
So here how would I give webpage content(html) to nokogiri?
Please suggest me here.
You can get the source of the page from selenium-webdriver by using the
page_sourcemethod:So your script could be:
That said, I do not know why you would want to use nokogiri instead of just selenium-webdriver.