• CEF浏览器代码收集


    CEF浏览器配置

     CefSettings cefSettings = new CefSettings();
                cefSettings.Locale = "zh-CN";
                cefSettings.CachePath = str + "cache";
                cefSettings.AcceptLanguageList = "zh-CN";
                //cefSettings.CefCommandLineArgs.Add("disable-application-cache", "1");
                //cefSettings.CefCommandLineArgs.Add("disable-session-storage", "1");
                Cef.Initialize(cefSettings); 
                CefSharpSettings.LegacyJavascriptBindingEnabled = true;
    View Code

     RegisterJsObject

            class JsEvent
            {
                public string MessageText = string.Empty;
                public void showTest()
                {
                    MessageBox.Show("this in C#.
    
    " + MessageText);
                    
                }
            }
    
            void intjs(ExtChromiumBrowser chromiumWeb)
            {
                var JsEvent = new JsEvent();
                chromiumWeb.RegisterJsObject("jsObj", JsEvent, BindingOptions.DefaultBinder);
            }
    
    function myfunction()
    {
         jsObj.MessageText = "hello";
        jsObj.showTest();
    }
    View Code

     COOKIE

     class CookieClear : ICookieVisitor
            {
                public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie)
                {
                    deleteCookie = true; return true; 
                } 
                public void Dispose() { }
    
            }
    
    CookieClear cookieClear;
                cookieClear = new CookieClear();
                if (Cef.GetGlobalCookieManager().VisitAllCookies(cookieClear))
                { 
    
                }
    View Code

     COOK

      public class CookieVisitor : ICookieVisitor
            {
    
                public CookieVisitor(string Domainurl)
                {
                    Domain = Domainurl;
                }
                public event Action<CefSharp.Cookie> SendCookie;
                public string cookies = "";
                public string Domain;
    
                public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie)
                {
                    deleteCookie = false;
                    if (SendCookie != null)
                    {
                        SendCookie(cookie);
    
                        cookies += cookie.Value;
                    }
    
                    return true;
                }
                public void Dispose() { }
            }
    
            static string cookies;
            /// 回调事件
            private static void visitor_SendCookie(CefSharp.Cookie obj)
            {
                cookies += obj.Domain.TrimStart('.') + "^" + obj.Name + "^" + obj.Value + "$";
            }
    
    
    CookieVisitor visitor = new CookieVisitor();
                visitor.SendCookie += visitor_SendCookie;
    
                if (Cef.GetGlobalCookieManager().VisitAllCookies(visitor))
                {
    
                }
    View Code
  • 相关阅读:
    7-3色彩平衡
    Flex 布局
    JS获取当前周
    虚树学习笔记
    当然,perl等脚本服务器是一般默认安装了,你入侵了一台主机,总不能先装配 Java 环境然后再开干吧?
    还有这种书,程序开发心理学(豆瓣)
    Codeforces Round #143 (Div. 2)
    Codeforces Round #142 (Div. 2)
    Codeforces Round #141 (Div. 2)
    2018-2019-1 20189221 书籍速读 第 1 周
  • 原文地址:https://www.cnblogs.com/bycnboy/p/9186510.html
Copyright © 2020-2023  润新知