Esempio n. 1
0
        public void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
        {
            Log.ShowLog(TAG, "OnResourceLoadComplete " + request.Url);
            //if (request.Url.Contains(PageUrlCharacteristic.QRCODE)) //验证码
            //{
            //    var filter = FilterManager.GetFileter(request.Identifier.ToString()) as CompletedResponseFilter;

            //    NotifyData?.Invoke(filter.dataAll.ToArray(), PageUrlCharacteristic.QRCODE);

            //    if (!saveAllRespnseForDebug)
            //    {
            //        FilterManager.DelFileter(request.Identifier.ToString());
            //    }
            //}

            //if (request.Url.EndsWith(PageUrlCharacteristic.MEMBERINFO_END) && response.StatusCode == 200)
            // { //用户信息.
            //    var filter = FilterManager.GetFileter(request.Identifier.ToString()) as CompletedResponseFilter;
            //    if (!saveAllRespnseForDebug)
            //    {
            //        FilterManager.DelFileter(request.Identifier.ToString());
            //    }
            //    NotifyData?.Invoke(filter.dataAll.ToArray(), PageUrlCharacteristic.MEMBERINFO_END);
            //    Log.ShowLog(TAG, "MEMINFO_END " + Encoding.Default.GetString(filter.dataAll.ToArray()));
            //}

            #region test
            // for test.
            if (saveAllRespnseForDebug)
            {//save all file to
                var filter = FilterManager.GetFileter(request.Identifier.ToString()) as CompletedResponseFilter;
                if (filter == null)
                {
                    return;
                }

                //  NotifyData?.Invoke(filter.dataAll.ToArray());
                var url = request.Url;

                url = url.Replace('?', '_').Replace('*', '_').Replace('|', '_').Replace('<', '_').Replace('>', '_')
                      .Replace(':', '_').Replace('/', '_');

                if (url.Length > 200)
                {
                    url = url.Substring(0, 200);
                }
                File.WriteAllBytes("E://htmlsave//" + url, filter?.dataAll.ToArray());
                //  FilterManager.DelFileter(request.Identifier.ToString());
            }
            #endregion
        }