Hi,
 
I'm trying to fetch a url similar to the one below:

http://www.metacafe.com/watch/yt-6gDlmA5SF9E/cow_slaughtering_on_eid_ul_zoha/
 
When I study the response, I see that the response status code is 404. However 
there is some content in the page that I would like to retrieve. Internet 
Explorer / Firefox browser reports the content to be of type text/html and when 
I do a view source, I see something like a html source. 
===========================================================================
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
                        <html xmlns="http://www.w3.org/1999/xhtml"; 
xml:lang="en" lang="en">
                        <head>                          <script 
type="text/javascript">
                                var startTime = new Date();
                                var reportURL = 'http://winter.metacafe.com';
                                var isBeta = 0;
=========================================================================

However with httpclient the fetched content seems to be unreadable and looks 
like a binary content. 

This is my sample file TestHttpFetch.java:

public class TestHttpFetch {
    public static void main(String args[]) {
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod(
                
"http://www.metacafe.com/watch/yt-6gDlmA5SF9E/cow_slaughtering_on_eid_ul_zoha/";);
        try {
            int statusCode = client.executeMethod(method);
            if (statusCode != HttpStatus.SC_OK) {
                System.err.println("Method failed: " + method.getStatusLine());
            }
            String response = method.getResponseBodyAsString();
            System.out.println("RESPONSE BODY: \n" + response);
        } catch (Exception e) {
            System.out.println("Exception occured:");
            e.printStackTrace();
        }
    }
}

Could you please let me know why I am getting this binary content?

Thanks in advance,
Subashini





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to