-1

How do i obtain pictures in fiddler core.

Fiddler.FiddlerApplication.BeforeResponse += delegate (Fiddler.Session oS) {
                Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
                oS.

                // Uncomment the following two statements to decompress/unchunk the
                // HTTP response and subsequently modify any HTTP responses to replace 
                // instances of the word "Microsoft" with "Bayden"
                //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
            };

I would expect this to be in this portion under the session portion. I am trying to replicate this effect in code.

enter image description here

This piece of code is obtained from the demo code in wiki

Modified the code based on the answer and this is the output

Fiddler.FiddlerApplication.BeforeResponse += delegate (Fiddler.Session oS) {
                if ((oS.responseCode == 200) && oS.oResponse.headers.ExistsAndContains("Content-Type", "image/"))
                {
                    oS.utilDecodeResponse();
                    Console.WriteLine("writing bytes");
                    Console.WriteLine(oS.requestBodyBytes);
                    // oS.responseBodyBytes is a byte[] containing the image

                    Bitmap oBMP = new Bitmap(new MemoryStream(oS.responseBodyBytes));


                    // Now oBMP is an image object which contains the picture...
                }

URL i am refreshing on:

http://baike.baidu.com/link?url=n8LTFN1PKt2Wp_mQul4-2SAFAXQ5BD5hmxu6m7PiC56Ix7htWUtZg7YqMkzBNnmjaYZpbTGS7HG6Mw6Qss2c2qYYjrqQeAyV2lsL1MusvIe

aceminer
  • 4,089
  • 9
  • 56
  • 104

1 Answers1

1

What specifically do you mean by "obtain picture"? Something like this?

if ((oS.responseCode == 200) && 
    oS.oResponse.headers.ExistsAndContains("Content-Type", "image/")) 
{
  oS.utilDecodeResponse();
  // oS.responseBodyBytes is a byte[] containing the image
  Bitmap oBMP = new Bitmap(new MemoryStream(oS.responseBodyBytes));
  // Now oBMP is an image object which contains the picture...
}
EricLaw
  • 56,563
  • 7
  • 151
  • 196
  • Yes I guess so. I will try to see if it works. I would like to extract the following packet as shown in the screen capture I got – aceminer Sep 16 '15 at 13:00
  • Invalid parameter. It's an exception – aceminer Sep 17 '15 at 11:06
  • I am having error at the bitmap line. I tried printing out the bytes using console.writeline but it appears that the byte string is empty. I am purely just refreshing the baidu page to capture the image – aceminer Sep 17 '15 at 12:21
  • What is the **exact** url? In your code sample, you're incorrectly using `requestBodyBytes` instead of `responseBodyBytes`. – EricLaw Sep 17 '15 at 12:27
  • I have added my URL in my question – aceminer Sep 17 '15 at 12:29
  • The value of interest is `oS.fullUrl`, not the HTML page. – EricLaw Sep 17 '15 at 12:37
  • I just want to extract all the pictures in the page. This code was taken from the demo code as I am extremely new to this Api hence I took it wholesale – aceminer Sep 17 '15 at 12:38