Forum: Ruby mechanize to access https links

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne001 (Guest)
on 2007-07-22 14:41
(Received via mailing list)
I would like to open and save to disk https tutorials which were
created with Flash i think.

To simplify, I login to the site with a webbrowser, so I don't need to
access a form. Just pages with links to the tutorials.

mechanize seems the tool to use from what I found out. I tried this
code found on this list:

require 'net/https'
require 'uri'

class HTTPS < Net::HTTP
   def initialize *a, &b
     super
     self.use_ssl = true
     self.verify_mode = OpenSSL::SSL::VERIFY_NONE
     self.set_debug_output $stderr
   end
end

# the url is of the form
url = 'https://tutorials.siteofinterest.com/?page=tutoria...

uri = URI.parse url

HTTPS.start(uri.host, uri.port) do |https|
   response = https.post("#{uri.path}?#{uri.query}")
   puts response.body
end

-----error message --->
opening connection to tutorials.siteofinterest.com...
opened
opurl2.rb:18:in `post': wrong number of arguments (1 for 2)
(ArgumentError)

I checked with IRB, uri seems to do its parsing, finding the host, the
path and the arguments after the question mark.

How can I find out what the second argument is that I need to put in?
or How can I find out what post Safari sends when I click on the same
link?
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne001 (Guest)
on 2007-07-22 18:13
(Received via mailing list)
require 'rubygems'
require 'mechanize'

mech = WWW::Mechanize.new
page =
mech.get('https://tutorials.siteofinterest.com/?
page=tutorialView&tId=47')

This code does return a page, but not the page I wanted. So there must
be something missing, a cookie or something which indicates I have
logged in.

If I try to access one of the links in ruby
mech.get('http://tutorials.siteofinterest.com/tutorials/Intro/Intface/
Intface.html')
I get an error, please provide username and password
while if I paste the http address in safari, it opens the tutorial
page. How do I find out what the browser is doing to satisfy the
tutorial web page server?
Be30361bb0b0c495e3077db43ad84b56?d=identicon&s=25 Aaron Patterson (Guest)
on 2007-07-23 00:46
(Received via mailing list)
On Mon, Jul 23, 2007 at 12:25:02AM +0900, anne001 wrote:
> logged in.
>
> If I try to access one of the links in ruby
> mech.get('http://tutorials.siteofinterest.com/tutorials/Intro/Intface/
> Intface.html')
> I get an error, please provide username and password
> while if I paste the http address in safari, it opens the tutorial
> page. How do I find out what the browser is doing to satisfy the
> tutorial web page server?

Make sure to clear all your cookies before you do that.  I recommend
getting Firefox, clearing your cookies, and using LiveHTTPHeaders.

  http://livehttpheaders.mozdev.org/

Hope that helps.
This topic is locked and can not be replied to.