Posts

Showing posts with the label ruby

Parsing with Mechanize

Image
Hello !  In my previous  article , we discussed about Nokigiri , a very useful HTML and XML parser i.e it helps in parsing or scraping the information available on a web page to use it in the Ruby program. But sometimes we just want to trigger some action , click button or automate the process on a website from a Ruby program.For example scheduling a social media post , automating a feed back (Yes , we are forced to give the feed back to the faculties on a web portal) or just submitting a form and many other features that are not provide by that particular website but you have to do it manually.This is where Mechanize comes to the rescue . It is one of the coolest ruby library that is very useful in scrapping as well as triggering any action on a web page. What's Mechanize ? According to the The Bastards Book of Ruby , "Sometimes, the challenge is navigating to the right page. This is the case with many websites that require you to fill out a form. It's not ...

Using Sinatra :A Web App Development Library(Part l)

Image
Ruby is blessed with several web application frameworks such as Ruby on Rails , Merb , Nitro,  Camping and Sinatra.Many of us might have heard about Ruby on Rails ,In simple words, Sinatra is an alternative to it and the other frameworks mentioned above.Sinatra was designed and developed by Blake Mizerany in 2007 and named after musician Frank Sinatra. In this article we'll learn about : i.   Installing and Setting up Sinatra ii.  Handling the HTTP Request Prerequisites:  One Must Know Ruby to proceed further. So let's begin : Installing and Setting up Sinatra:   i.  Open the Terminal. ii.   Type "gem install sinatra" without " ". Voila! The gem got install.Now its time to Test it.So, for this we will create  file named "app.rb" and type: require "sinatra" #to use the sinatra module and run the app by typing "ruby /directory_name/app.rb" without ""  and then go t...