From: Alice Gheorghiu Date: 2009-06-18T04:39:30+09:00 Subject: Re: Download csv file from secure web site (https Alice Gheorghiu wrote: > Joel VanderWerf wrote: >> Alice Gheorghiu wrote: > Tried ssh and I am getting error as follows in the ssh command: > $ ssh username@https://www.desired_website.com/pageWLinkToReport.php > $ ssh: https://www.desired_website.com/pageWLinkToReport.php: Name or > service not known > >> If it works at all, it would be something like: >> ssh username@desired_website.com > >> but the fact that there is a https interface does not imply that there >> is an ssh interface. They are handled by different server software, and >> unless the provider explicitly set up an ssh server, it won't be there. >> And for that matter, having an account on the https server doesn't imply >> having an account that you can access via ssh, even if the ssh server is >> running. >> >> It sounds like a task for something like mechanize[1], but I don't know >> how it is with https. Some others on this list will know, I hope... or >> try googling for "ruby mechanize https". >> [1] http://mechanize.rubyforge.org/mechanize/ > You are right, whereby their reluctance to assist. The site is a good > starting point. Will browse and will be back with the code if I can make > it work. Thanks a million. I was able to work through the code: here it is: !#/usr/bin/rb #################################################### #This program handles files from Vitelity web-site # #using nokogiri mechanize package # #Created on 06/09/09 # #By Alice G. # #################################################### require 'rubygems' require 'mechanize' require 'date' unless ARGV.size == 3 puts "Usage: Enter username, password and e-mail address" exit end #Define the cdr start and end date d = DateTime.now #Create a new object from mechanize class to parse the web pages a = WWW::Mechanize.new a.get('http://portal.vitelity.net/login.php') do |page| # Click the login link #login_page = a.click(page.links.text(/Log In/)) #login_page = a.click(page.links.find { |link| /Log In/.match link.text }) # Submit the login form my_page = page.form_with(:action => 'signin.php') do |f| f.username = ARGV[0] f.pass = ARGV[1] end.click_button # Click the Call Detail Report link on the Vitelity index page #cdr_page = a.click(my_page.links.find { |link| /Call Records/.match link.text}) cdr_page = a.get('http://portal.vitelity.net/index.php?p=cdr') cdr_report=cdr_page.form_with(:action => 'index.php') do |f| f.toemail = ARGV[2] f.frommonth=d.month f.fromday = d.day - 1 f.fromyear = d.year f.tomonth=d.month f.today=d.day f.toyear=d.year end.click_button end The script accepts 3 parameters, username, password to the site and the e-mail where the file should be sent. To get info on form field names you need to source the web page and refer to them in your source code. -- Posted via http://www.ruby-forum.com/.