• 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...

  • 相关阅读:
    成都Uber优步司机奖励政策(3月8日)
    北京Uber优步司机奖励政策(3月8日)
    滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(3月8日)
    hadoop包含哪些技术?
    hadoop命令详解
    hadoop Shell命令详解
    hadoop hdfs uri详解
    Android Activity/Service/Broadcaster三大组件之间互相调用
    Service实时向Activity传递数据案例
    Android Service获取当前位置(GPS+基站)
  • 原文地址:https://www.cnblogs.com/yfann/p/2912642.html
Copyright © 2020-2023  润新知