how to get a http directory listing

C

Carlos Diaz

Hi,

Has anyone ever tried to do something like this? I'm trying to log in
to a url and get a listing of all the files on that url. For example,
with wget I can fetch the files this way:

wget http://username:[email protected]/logs/somelog.log

this would get the individual file and download it to my local machine.
However, I'm trying to automate this script to go out and look at the
contents of this directory and do something for each file in there. For
example, I want to do something like this:

Dir.foreach("http://username:[email protected]/logs") {|x| <do some
logic here>}

However, I'm not sure if there is a simple way to do something like this
in Ruby. Anyone encountered this before?

Thanks in advance,
Carlos
(Ruby Rookie)
 
R

Robert Klemme

Carlos said:
Hi,

Has anyone ever tried to do something like this? I'm trying to log in
to a url and get a listing of all the files on that url. For example,
with wget I can fetch the files this way:

wget http://username:[email protected]/logs/somelog.log

this would get the individual file and download it to my local
machine. However, I'm trying to automate this script to go out and
look at the contents of this directory and do something for each file
in there. For example, I want to do something like this:

Dir.foreach("http://username:[email protected]/logs") {|x| <do some
logic here>}

However, I'm not sure if there is a simple way to do something like
this in Ruby. Anyone encountered this before?

Problem is, that there is no standard directory listing mechanism for
HTTP. Most servers even forbid to list directory contents.

Maybe wget does the job already.

Kind regards

robert
 
D

daz

Carlos said:
Hi,

Has anyone ever tried to do something like this? I'm trying to log in
to a url and get a listing of all the files on that url. For example,
with wget I can fetch the files this way:

wget http://username:[email protected]/logs/somelog.log

this would get the individual file and download it to my local machine.
However, I'm trying to automate this script to go out and look at the
contents of this directory and do something for each file in there. For
example, I want to do something like this:

Dir.foreach("http://username:[email protected]/logs") {|x| <do some
logic here>}

However, I'm not sure if there is a simple way to do something like this
in Ruby. Anyone encountered this before?


Niklas Frykholm may have tussled with this problem:

http://raa.ruby-lang.org/project/webfetcher/

=> http://www.acc.umu.se/~r2d2/programming/ruby/webfetcher/

Worth a look, for ideas ?


daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top