ruby on rails - Fetch data stored in URL -


new here, wanted know how fetch data particular url , store respective in database , later access using rails.

however, able fetch data url , received data in xml format , able display it, being done manually, want know how data url, in hash form , contains lot of attributes.

need store attributes in database , retrieve value url directly.

for use nokogiri gem more information can read http://nokogiri.org/tutorials/parsing_an_html_xml_document.html  gives following commands of nokogiri... please avoide # sign  doc = nokogiri::html(open(your site url)) # specific selector's matching elements # doc.css("div")  # specific selector's first matching element # doc.at_css("div")  # matching element id name # doc.at_css("input#id name") # eg: doc.at_css("input#resultscount")  # matching element class name # doc.at_css("div.class name") # eg: doc.at_css("div.results")   # file.open("#{rails.root}/public/aa.txt","w+").write(doc.css("div#search-result-listings"))  # fields data eg. take value of input field id resultscount # <input type="hidden" name="resultscount" id="resultscount" value="12321" /> # doc.at_css("input#resultscount")["value"]  # results # search_results=doc.at_css("div#search-result-listings").css("div.result.clearfix")   #find tag ("<ul>") , find elements , children dc=doc.at_css("div#search-result-listings") #find elements of ul such li childs dc.at_css("ul").elements #if childs of elements dc.at_css("ul").elements.children #if want print child value use "text" property dc.at_css("ul").elements.children[0].text #if want child data use dc.at_css("ul").elements.children.text or dc.at_css("ul").elements.text or dc.at_css("ul").text 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -