Получение картинок из ядра скрипача
Как получить картинки в ядре скрипача.
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");
};
Я ожидаю, что это будет в этой части под частью сессии. Я пытаюсь повторить этот эффект в коде.
Этот кусок кода получен из демонстрационного кода в вики
Модифицированный код основан на ответе, и это вывод
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, на котором я обновляюсь:
1 ответ
Решение
Что конкретно вы подразумеваете под "получить картинку"? Что-то вроде этого?
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...
}