--00504502cc9f8ec74904771a2db0
Content-Type: text/plain; charset=UTF-8

Your problem is that you're catching the exception outside of the loop.  Try
something like:


list  O.foreach(url_file) do |line|
  begin
    agent.get(line)
  rescue WWW::Mechanize::ResponseCodeError
    puts "Page not found"
  end
end




On Wed, Oct 28, 2009 at 7:23 PM, Kyle Johnson <kylearippee / gmail.com> wrote:

> Hi, I have been having a bit of an issue. I am trying to create a
> program that will allow me to run a file containing a directory listing
> line by line through a proxy. I am designing this to help with my job, I
> am a web application pen tester. The only issue with the code is I am
> running into 404 and 502 errors which is to be expected. I would like to
> find a way to handle the exception without bringing the execution to a
> halt or deleting anything from the original directory listing. Here is
> my code
>
> begin
>  list  O.foreach(url_file) {|line| agent.get(line)}
> rescue WWW::Mechanize::ResponseCodeError
>  puts "Page not found"
> end
>
> Please if anyone has an idea on how to make this work I would very much
> appreciate the help.
> --
> Posted via http://www.ruby-forum.com/.
>
>

--00504502cc9f8ec74904771a2db0--