Blog Archives

Ubuntu Server Basic Libraries [ with SSL, nokogiri, postgress and nodjs ]

To install basic tools and nokogiri libraries sudo apt-get install git build-essential patch ruby-dev zlib1g-dev liblzma-dev sudo apt-get install -y libssl-dev libreadline-dev Uglifier required library sudo apt-get install nodejs Postgres required library sudo apt-get install libpq-dev Install and Setup Nginx

Tagged with:
Posted in Nokogiri, postgres, Ubuntu

Nokogiri XML Attributes reading of some node

<rss> <channel> <item> <enclosure url=”http://www.leonardo-hotels.mobi/octopus/Upload/Images/Resorts/batyam%20deluxe%20livingroom%20255.jpg&#8221; length=”100″ type=”image/jpeg”/> </item> </channel> </rss> To access tag’s url attribute root.at_xpath(“rss/channel/item”).xpath(‘enclosure’).attribute(‘url’) def read_by_nokogiri(url) url, timeout = url.strip, 60 uri = URI.parse(URI.encode(url)) http = Net::HTTP.new(uri.host, uri.port) http.open_timeout, http.read_timeout = timeout, timeout http.request_get(uri.request_uri) do |response| root =

Tagged with:
Posted in Nokogiri, XML

Search subnode / subtree in nokogiri

Difference b/w node.xpath and node.at_xpath xpath: Used to search specific node’s subtree at_xpath: Don’t search for subtree of specific node

Tagged with: ,
Posted in Nokogiri, Parser/Scrapper

Nokogiri Xml Parsing

Q: How to parse Xml Document with Nokogiri? Answer: In model: 1) Put this line in your gem file. gem ‘nokogiri’ 2) Require these after installing nokogiri gem in you project. require ‘open-uri’ # required for this require ‘net/http’ #

Tagged with: , ,
Posted in Nokogiri

Nokogiri Html Parsing

Q: How to parse Html Document with Nokogiri? Answer: In model: 1) Put this line in your gem file.   gem ‘nokogiri’ 2) Require these after installing nokogiri gem in you project. require ‘open-uri’ # required for this require ‘net/http’ #

Tagged with: , , ,
Posted in Nokogiri, Parser/Scrapper
StackOverFlow
Categories
Archives