From: Arun Kumar Date: 2009-04-06T22:50:33+09:00 Subject: Code duplication Hi all, The following is the code for extracting the html contents of a website. I have included the code in case url redirect and BadRequest error. #getting the HTTP response from 'uri' response = Net::HTTP.get_response(uri) case response # if the url is redirecting then fetch the contents of the redirected url when Net::HTTPRedirection then uri = URI.parse(response['Location']) response = Net::HTTP.get_response(uri) # in case of a bad request error when Net::HTTPBadRequest then http = Net::HTTP.start(uri.host, uri.port) #getting the html data by setting the path as '/' and using a user agent response = http.get("/", "User-Agent"=>"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)") end data = response.body My tutor is saying that there is a duplication in the above code. ie. code for html reading is specified twice without any purpose and it should be removed. I've no idea where there is a mistake. I'm a newbee to ruby and i don't understand the problem correctly or where things went wrong. Can anyone please help me to find the mistake. Thanks in advance. Regards Arun -- Posted via http://www.ruby-forum.com/.