问题描述
我想将所有与某些网页一起加载的png图像保存到单独的文件夹中.我正在Fiddler脚本[CustomRules.js]中使用以下代码.
I want to save all png images that are loaded along with some webpage into a separate folder.I am using below code with in Fiddler Script [CustomRules.js].
static function OnBeforeResponse(oSession: Session)
{
if(oSession.url.EndsWith(".png"))
{
oSession.SaveResponseBody();
}
//Actual content of OnBeforeResponse function.
}
问题在这里,我找不到程序文件/文档中保存的任何图像.
Problem here is, I was unable to find any image got saved within Program files/Documents.
"SaveResponseBody()"将在何处保存HTTP响应正文?
Where do "SaveResponseBody()" will save the HTTP Response Body?
我们可以给我们自己的自定义文件夹吗?
Can we give our own custom folder?
我的Fiddler版本是(v4.4.5.6)
My Fiddler version is (v4.4.5.6)
推荐答案
默认的 SaveResponseBody()
方法将文件保存到您的 \ Documents \ Fiddler2 \ Captures \
文件夹中.如果要使用其他名称,请使用接受文件名的重载.您应该检查Response的状态码为200,以确保您不试图保存不包含正文的HTTP/304响应.另外,您可能不希望查看URL,而是要检查响应的类型.
The default SaveResponseBody()
method saves the files to your \Documents\Fiddler2\Captures\
folder. If you want to use a different name, use the overload that accepts a filename. You should check the Response's status code is 200 to ensure that you're not trying to save off HTTP/304 responses which won't contain a body. Also, rather than looking at the URL, you probably want to check the response's type.
因此,您最终得到的是这样的东西:
So you end up with something like this:
if ((oSession.responseCode == 200) &&
oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/png"))
{
SaveResponseBody("C:\\temp\\" + oSession.SuggestedFilename);
}
注意:手动执行此操作的方法是转到"Web会话"列表下方的QuickExec框,键入 select png
并按Enter,然后单击文件">导出">选定的会话">原始文件"
Note: The manual way of doing this would be to go to the QuickExec box below the Web Sessions list, type select png
and hit Enter, then click File > Export > Selected Sessions > Raw Files.
这篇关于提琴手脚本-SaveResponseBody()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!