• fiddler2 脚本


    customize rules

    public static var mp3BasePath:String = "F:\doubanMP3";
    public static var doubanPlayList:String=null;
    public static var imgBasePath:String = "F:\Img";

    static function OnBeforeResponse(oSession: Session) {
    if (m_Hide304s && oSession.responseCode == 304) {
    oSession["ui-hide"] = "true";
    }

    DownloadDoubanMP3(oSession);
    }

    static function DownloadDoubanMP3(oS:Session)
    {
    if(oS.HostnameIs("douban.fm")&&oS.uriContains("playlist"))
    {
    LogString("++++++++++PlayList-----------");
    LogString(oS.url);
    oS.utilDecodeResponse();
    var temp:String=System.Text.Encoding.UTF8.GetString(oS.responseBodyBytes);
    if(temp!="\"ok\""&&temp.Replace(/(^\s*)|(\s*$)/g, "")!="")
    {
    doubanPlayList=temp;
    //FiddlerObject.alert(doubanPlayList);
    LogString("Content:"+temp);
    }
    //FiddlerObject.alert(doubanPlayList);
    LogString("----------PlayList+++++++++++");
    }
    if(oS.hostname.Contains("douban.com")&&oS.url.EndsWith(".mp3"))
    {
    LogString("++++++++++MP3-----------");
    if(oS.oResponse.headers.ExistsAndContains("Content-Type", "audio/mpeg")){
    //FiddlerObject.alert(doubanPlayList);
    //FiddlerObject.alert(oSession.url.Substring(oSession.url.LastIndexOf("/")));
    var reg:RegExp=new RegExp(".*\"artist\":\"(.*?)\".*?"+oS.url.Substring(oS.url.LastIndexOf("/"))+".*?\"title\":\"(.*?)\".*?}");
    LogString("Reg:"+reg);
    LogString("PlayList:"+doubanPlayList);
    var arr:Array=reg.exec(doubanPlayList);
    // FiddlerObject.alert(arr[1]+" "+arr[2]);
    var path: String = System.IO.Path.Combine(mp3BasePath, arr[1]+"-"+arr[2]+".mp3");
    LogString("Path:"+path);
    if(!System.IO.File.Exists(path))
    {
    oS.SaveResponseBody(path);
    }
    }
    LogString("---------MP3++++++++++++");
    }
    }

    static function DownloadImages(oS:Session)
    {
    if ((oS.oResponse != null) && (oS.oResponse.headers != null)&&oS.oResponse.headers.ExistsAndContains("Content-Type", "image/"))
    {
    //FiddlerObject.alert("ok");
    try{
    var oMS: System.IO.MemoryStream = new System.IO.MemoryStream(oS.responseBodyBytes);
    var i:System.Drawing.Bitmap = new System.Drawing.Bitmap(oMS);
    if(i.Width>400&i.Height>400)
    {
    var path:String=System.IO.Path.Combine(imgBasePath,Guid.NewGuid()+oS.url.Substring(oS.url.LastIndexOf(".")));
    i.Save(path);
    }
    }
    catch(e) { return e; }
    }
    }

    To be continue...

  • 相关阅读:
    父级和 子集 controller 之间的通讯
    ui-router(三)controller与template
    ui-router详解(二)ngRoute工具区别
    关于MySql全文索引
    Yii提供的Htmler助手checkboxList可自定义Checkbox输出格式
    添加和删除索引以及如何给中间表添加两个主键
    设置数据库及表的默认字符集
    保存数据的时候报类型错误的原因和解决方案
    金融经济
    YII获取刚插入数据的id主键
  • 原文地址:https://www.cnblogs.com/yfann/p/2912642.html
Copyright © 2020-2023  润新知