CefSharp禁止彈出新窗體,在同一視窗打開鏈接,或者在新Tab頁打開鏈接,並且支持帶type="POST" target="_blank"的鏈接

来源:https://www.cnblogs.com/s0611163/archive/2019/12/13/12034090.html

說明:在同一視窗打開鏈接,只要稍加改造就可以實現,這裡實現的是在新Tab頁打開鏈接,並且支持帶type="POST" target="_blank"的鏈接 github和bitbucket上相關問題: 1、WPF empty POST data when using custom popup htt ...


 說明:在同一視窗打開鏈接,只要稍加改造就可以實現,這裡實現的是在新Tab頁打開鏈接,並且支持帶type="POST" target="_blank"的鏈接

 

github和bitbucket上相關問題:

1、WPF empty POST data when using custom popup    https://github.com/cefsharp/CefSharp/issues/1267

2、CefLifeSpanHandler, customized OnBeforePopup problem    https://bitbucket.org/chromiumembedded/cef/issues/1949/

 

解決(CefSharp版本75.1.143.0):

一、實現IRequestHandler介面

using CefSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;

namespace CefSharpDemo
{
    public class RequestHandler : IRequestHandler
    {
        private ExtChromiumBrowser _browser;

        public RequestHandler(ExtChromiumBrowser browser)
        {
            _browser = browser;
        }

        public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            return false;
        }

        public IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
        {
            if (request.Method.ToUpper() == "POST" && request.PostData != null)
            {
                if (request.PostData.Elements.Count > 0)
                {
                    _browser.PostData = new byte[request.PostData.Elements[0].Bytes.Length];
                    request.PostData.Elements[0].Bytes.CopyTo(_browser.PostData, 0);
                }
            }
            return null;
        }

        public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
        {
            return false;
        }

        public bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
        {
            return false;
        }

        public bool OnOpenUrlFromTab(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture)
        {
            return false;
        }

        public void OnPluginCrashed(IWebBrowser chromiumWebBrowser, IBrowser browser, string pluginPath)
        {

        }

        public bool OnQuotaRequest(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
        {
            return false;
        }

        public void OnRenderProcessTerminated(IWebBrowser chromiumWebBrowser, IBrowser browser, CefTerminationStatus status)
        {

        }

        public void OnRenderViewReady(IWebBrowser chromiumWebBrowser, IBrowser browser)
        {

        }

        public bool OnSelectClientCertificate(IWebBrowser chromiumWebBrowser, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback)
        {
            return false;
        }
    }
}
View Code

二、實現ILifeSpanHandler介面

using CefSharp;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using Utils;

namespace CefSharpDemo
{
    public class CefLifeSpanHandler : CefSharp.ILifeSpanHandler
    {
        private static LimitedTaskScheduler _scheduler = new LimitedTaskScheduler(2);

        public CefLifeSpanHandler()
        {

        }

        public bool DoClose(IWebBrowser browserControl, CefSharp.IBrowser browser)
        {
            if (browser.IsDisposed || browser.IsPopup)
            {
                return false;
            }

            return true;
        }

        public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser)
        {

        }

        public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
        {
        }

        public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
        {
            var chromiumWebBrowser = (ExtChromiumBrowser)browserControl;

            chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
            {
                BrowserPopupWin win = new BrowserPopupWin();
                win.ShowInTaskbar = false;
                win.Height = 0;
                win.Width = 0;
                win.Show();

                IntPtr handle = new WindowInteropHelper(win).Handle;
                windowInfo.SetAsChild(handle);

                _scheduler.Run(() =>
                {
                    WaitUtil.Wait(() => chromiumWebBrowser.PostData);

                    IRequest request = null;
                    if (chromiumWebBrowser.PostData != null)
                    {
                        request = frame.CreateRequest();
                        request.Url = targetUrl;
                        request.Method = "POST";

                        request.InitializePostData();
                        var element = request.PostData.CreatePostDataElement();
                        element.Bytes = chromiumWebBrowser.PostData;
                        request.PostData.AddElement(element);
                        chromiumWebBrowser.PostData = null;
                    }

                    chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
                    {
                        NewWindowEventArgs e = new NewWindowEventArgs(targetUrl, request);
                        chromiumWebBrowser.OnNewWindow(e);
                    }));

                    chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
                    {
                        win.Close();
                    }));
                });
            }));

            newBrowser = null;
            return false;
        }

    }
}
View Code

三、擴展ChromiumWebBrowser

using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CefSharpDemo
{
    public class ExtChromiumBrowser : ChromiumWebBrowser
    {
        public byte[] PostData { get; set; }

        public ExtChromiumBrowser()
            : base()
        {
            this.LifeSpanHandler = new CefLifeSpanHandler();
            this.DownloadHandler = new DownloadHandler(this);
            this.MenuHandler = new MenuHandler();
            this.KeyboardHandler = new KeyboardHandler();
            this.RequestHandler = new RequestHandler(this);
        }

        public event EventHandler<NewWindowEventArgs> StartNewWindow;

        public void OnNewWindow(NewWindowEventArgs e)
        {
            if (StartNewWindow != null)
            {
                StartNewWindow(this, e);
            }
        }

        public void ClearHandlers()
        {
            //如果不清理Handler,會導致子進程CefSharp.BrowserSubprocess.exe無法釋放
            this.LifeSpanHandler = null;
            this.DownloadHandler = null;
            this.MenuHandler = null;
            this.KeyboardHandler = null;
        }
    }
}
View Code

四、封裝ExtChromiumBrowser(BrowserCtrl控制項)

using CefSharp;
using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Utils;

namespace CefSharpDemo
{
    /// <summary>
    /// 瀏覽器用戶控制項
    /// </summary>
    public partial class BrowserCtrl : UserControl, IDisposable
    {
        #region 外部方法
        /*
        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern int CloseWindow(IntPtr hWnd);
        [DllImport("User32.dll", EntryPoint = "GetWindowText")]
        private static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount);
        */
        #endregion

        #region 變數屬性事件
        private static bool _isCefInited = false;

        private static object _lockObject = new object();

        private JSObject _jsObject;

        private bool _firstLoad = true;

        /// <summary>
        /// 在此事件中設置URL(此事件已線上程中執行,此事件已對錯誤情況進行處理)
        /// </summary>
        public event EventHandler SetUrlEvent;

        /// <summary>
        /// URL
        /// </summary>
        public string Url { get; set; }

        public IRequest Request { get; set; }

        /// <summary>
        /// 瀏覽器FrameLoadEnd事件
        /// </summary>
        public event EventHandler FrameLoadEnd;

        private ExtChromiumBrowser _browser;

        public ExtChromiumBrowser Browser
        {
            get
            {
                WaitUtil.Wait(() => this._browser != null && this._browser.IsInitialized && _isCefInited);

                return this._browser;
            }
        }

        private static LimitedTaskScheduler _scheduler = new LimitedTaskScheduler(2);
        #endregion

        #region 構造函數
        public BrowserCtrl()
        {
            InitializeComponent();
            if (DesignerProperties.GetIsInDesignMode(this)) return;

            this.Loaded += BrowserCtrl_Loaded;

            lock (_lockObject)
            {
                if (!_isCefInited)
                {
                    _isCefInited = true;
                    InitCef();//初始化CefSharp
                }
            }

            _browser = new ExtChromiumBrowser();
            BindBrowser(_browser);
            grid.Children.Add(_browser);
        }
        #endregion

        #region BrowserCtrl_Loaded
        private void BrowserCtrl_Loaded(object sender, RoutedEventArgs e)
        {

        }
        #endregion

        #region SetMapCtrl
        /// <summary>
        /// 設置Map控制項介面,用於C#和JS互操作
        /// </summary>
        public void SetMapCtrl(IMapCtrl mapCtrl)
        {
            _jsObject.MapCtrl = mapCtrl;
        }
        #endregion

        #region Dispose 釋放資源
        /// <summary>
        /// 釋放資源
        /// </summary>
        public void Dispose()
        {
            //如果有彈出視窗則先釋放它
            //foreach (UIElement item in grid.Children)
            //{
            //    if (item is BrowserContainer)
            //    {
            //        (item as BrowserContainer).ClearResource();
            //    }
            //}

            _browser.ClearHandlers();
            if (_browser != null && !_browser.IsDisposed)
            {
                _browser.Dispose();
            }
        }
        #endregion

        #region Load
        public void Load(string url)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                loadingWait.Visibility = Visibility.Visible;
                Url = url;
                _scheduler.Run(() =>
                {
                    #region Wait
                    WaitUtil.Wait(() =>
                    {
                        if (this._browser == null) return false;
                        if (!this._browser.IsInitialized) return false;
                        if (!_isCefInited) return false;
                        bool isBrowserInitialized = false;
                        this.Dispatcher.Invoke(() =>
                        {
                            isBrowserInitialized = this._browser.IsBrowserInitialized;
                        });
                        if (!isBrowserInitialized) return false;
                        return true;
                    });
                    #endregion

                    _browser.Load(Url);
                });
            }
        }
        #endregion

        #region LoadUrl
        private void LoadUrl()
        {
            if (_firstLoad)
            {
                _firstLoad = false;

                _scheduler.Run(() =>
                {
                    #region Wait
                    WaitUtil.Wait(() =>
                    {
                        if (this._browser == null) return false;
                        if (!this._browser.IsInitialized) return false;
                        if (!_isCefInited) return false;
                        bool isBrowserInitialized = false;
                        this.Dispatcher.Invoke(() =>
                        {
                            isBrowserInitialized = this._browser.IsBrowserInitialized;
                        });
                        if (!isBrowserInitialized) return false;
                        return true;
                    });
                    #endregion

                    if (Url == null && SetUrlEvent != null)
                    {
                        try
                        {
                            SetUrlEvent(this, null);
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Error(ex, "BrowserCtrl LoadUrl error 獲取URL失敗");
                        }
                    }
                    else
                    {
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            loadingWait.Visibility = Visibility.Collapsed;
                        }));
                    }

                    if (Url != null)
                    {
                        try
                        {
                            if (Request == null)
                            {
                                _browser.Load(Url);
                            }
                            else
                            {
                                _browser.Load(Url);
                                _browser.GetMainFrame().LoadRequest(Request);
                                Request = null;
                            }
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Error(ex, "BrowserCtrl LoadUrl error Load URL失敗");
                        }
                    }
                    else
                    {
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            loadingWait.Visibility = Visibility.Collapsed;
                        }));
                    }
                });
            }
        }
        #endregion

        #region BindBrowser
        private void BindBrowser(ExtChromiumBrowser browser)
        {
            _jsObject = new JSObject();
            browser.RegisterJsObject("jsObj", _jsObject, new CefSharp.BindingOptions { CamelCaseJavascriptNames = false });

            browser.IsBrowserInitializedChanged += (ss, ee) =>
            {
                LoadUrl();
            };
            browser.FrameLoadStart += (ss, ee) =>
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    (ss as ExtChromiumBrowser).Focus();
                }));
            };
            browser.FrameLoadEnd += (ss, ee) =>
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    loadingWait.Visibility = Visibility.Collapsed;
                }));
                if (FrameLoadEnd != null)
                {
                    FrameLoadEnd(null, null);
                }
            };
            browser.KeyDown += (ss, ee) =>
            {
                if (ee.Key == Key.F5)
                {
                    try
                    {
                        browser.Reload();
                    }
                    catch (Exception ex)
                    {
                        LogUtil.Error(ex, "ExtChromiumBrowser Reload error");
                    }
                }
            };
            browser.PreviewTextInput += (o, e) =>
            {
                foreach (var character in e.Text)
                {
                    // 把每個字元向瀏覽器組件發送一遍
                    browser.GetBrowser().GetHost().SendKeyEvent((int)WM.CHAR, (int)character, 0);
                }

                // 不讓cef自己處理
                e.Handled = true;
            };
            browser.LoadError += (s, e) =>
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    loadingWait.Visibility = Visibility.Collapsed;
                }));
            };
        }
        #endregion

        #region RegisterJsObject
        public void RegisterJsObject(string name, object objectToBind, BindingOptions options = null)
        {
            try
            {
                if (_browser != null)
                {
                    _browser.RegisterJsObject(name, objectToBind, options);
                }
            }
            catch (Exception ex)
            {
                LogUtil.Error(ex, "BrowserCtrl RegisterJsObject 錯誤");
            }
        }
        #endregion

        #region 初始化CefSharp
        public static void InitCef()
        {
            string cefsharpFolder = "CefSharp";

            var settings = new CefSettings();
            //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others.
            //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified. 
            settings.CachePath = cefsharpFolder + "/cache"; //設置cache目錄

            settings.MultiThreadedMessageLoop = true;
            CefSharpSettings.FocusedNodeChangedEnabled = true;
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            CefSharpSettings.ShutdownOnExit = true;
            CefSharpSettings.SubprocessExitIfParentProcessClosed = true;

            string logDir = AppDomain.CurrentDomain.BaseDirectory + cefsharpFolder + "/log/";
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            settings.BrowserSubprocessPath = AppDomain.CurrentDomain.BaseDirectory + cefsharpFolder + "/CefSharp.BrowserSubprocess.exe";
            settings.LogFile = logDir + DateTime.Now.ToString("yyyyMMdd") + ".log";
            settings.LocalesDirPath = AppDomain.CurrentDomain.BaseDirectory + cefsharpFolder + "/locales";
            settings.CefCommandLineArgs.Add("disable-gpu", "1");
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");

            if (!Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: new BrowserProcessHandler()))
            {
                throw new Exception("Unable to Initialize Cef");
            }
        }
        #endregion

    }
}
View Code

五、MainWindow測試代碼

using CefSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Utils;

namespace CefSharpDemo
{
    /// <summary>
    /// CefSharp Demo 窗體
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            tabControl.AddTabItemEvent += tabControl_AddTabItemEvent;
            Application.Current.MainWindow = this;
        }

        private void tabControl_AddTabItemEvent(object sender, EventArgs e)
        {
            //CreateTabItem("https://www.cnblogs.com/");
            CreateTabItem("file:///D:/_程式/CefSharpDemo/post.html");
        }

        /// <summary>
        /// 新增Tab頁
        /// </summary>
        private void CreateTabItem(string url = null, IRequest request = null)
        {
            TabItem tabItem = new TabItem();
            tabItem.Header = "新標簽頁";
            BrowserDemoCtrl ctrl = new BrowserDemoCtrl();
            ctrl.browserCtrl.Browser.StartNewWindow += (s, e) =>
            {
                CreateTabItem(e.TargetUrl, e.Request);
            };
            ctrl.browserCtrl.SetUrlEvent += (s, e) =>
            {
                ctrl.browserCtrl.Url = url;
                ctrl.browserCtrl.Request = request;
            };
            tabItem.Content = ctrl;
            tabControl.Items.Add(tabItem);
            tabControl.SelectedItem = tabItem;
            ScrollViewer scrollViewer = tabControl.Template.FindName("scrollViewer", tabControl) as ScrollViewer;
            scrollViewer.ScrollToRightEnd();
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            tabControl.CloseAllTabItem(); //關閉窗體清理資源

            //程式退出時刪除cache
            CefSharp.Cef.Shutdown();
            string cachePath = AppDomain.CurrentDomain.BaseDirectory + "CefSharp\\cache";
            if (Directory.Exists(cachePath))
            {
                foreach (string path in Directory.GetDirectories(cachePath))
                {
                    Directory.Delete(path, true);
                }
                foreach (string file in Directory.GetFiles(cachePath))
                {
                    if (!file.ToLower().Contains("cookies"))
                    {
                        File.Delete(file);
                    }
                }
            }
        }
    }
}
View Code

 六、測試html代碼post.html

<!DOCTYPE html>
<html>
<head>
    <title>CefSharpDemo</title>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <style type="text/css">
    </style>

    <script type="text/javascript">
    </script>
</head>
<body>
    <!--enctype="multipart/form-data"-->
    <form method="post" action="http://localhost:1209/netcms/" target="_blank">
        <span>name:</

	
您的分享是我們最大的動力!

更多相關文章
  • 比如我們需要ASP.NET Core 中需要通過PDF來進行某些簡單的報表開發,隨著這並不難,但還是會手忙腳亂的去搜索一些資料,那麼恭喜您,這篇帖子會幫助到您,我們就不會再去浪費一些寶貴的時間。 在本文中我們將要使用DinkToPDF來處理我們在.NET Core Web 程式中進行構建PDF文檔! ...
  • EulerOS其實出來有一段時間了,一直在關註,單是僅僅也只是停留在觀望的階段,目前還沒有接入的打算;正好看到園子里的兄弟分享了華為雲免費試用的活動後,難捺激動的心情,我馬上去申請試用了一臺伺服器。 ...
  • 如果要在程式中使用DbContext,則需要先在Nuget中安裝Microsoft.EntityFrameworkCore.SqlServer ...
  • 原文:https://blogs.msdn.microsoft.com/mazhou/2017/12/12/c-7-series-part-7-ref-returns/ 背景 有兩種方法可以將一個值傳遞給一個方法: 例如,FCL(.NET Framework Class Library)中的Arra ...
  • 引用類庫 1.Install-Package Microsoft.Extensions.Caching.Memory MemoryCacheOptions 緩存配置 1.ExpirationScanFrequency 獲取或設置對過期項的連續掃描之間的最短時間間隔 2.SizeLimit 緩存是沒有 ...
  • 對於地圖坐標偏移,以leaflet為例,有如下解決辦法 方法1、修改leaflet源碼,解決地圖坐標偏移問題 方法2、將點位真實的經緯度經過偏移演算法,添加到加密的地圖上 方法3、直接對離線地圖瓦片進行糾偏 方法1需要修改源碼 方法2有缺陷,地圖依然是偏移的,如果把地圖經緯度顯示出來,經緯度也是不對的 ...
  • 9月份的時候,微軟宣佈正式發佈C 8.0,作為.NET Core 3.0發行版的一部分。C 8.0的新特性之一就是預設介面實現。在本文中,我們將一起來聊聊預設介面實現。 作者:依樂祝 原文鏈接:https://www.cnblogs.com/yilezhu/p/12034584.html 提前說下: ...
  • 前言 公司項目需要做個畫線縮放,我司稱之為瞳距縮放,簡而言之就是:2張圖,從第一張圖畫一條線,再從第二個圖畫一條線,第二條線以第一條為基準,延長到一致的長度,並同比縮放圖片;文字太枯燥,請先實例圖 例子1:以皮卡丘為例,我要把路飛的拳頭縮放到皮卡丘頭那麼大 例子2:以皮卡丘的基準,縮小路飛,與其身高 ...
一周排行
  • 比如要拆分“呵呵呵90909086676喝喝999”,下麵當type=0返回的是中文字元串“呵呵呵,喝喝”,type=1返回的是數字字元串“90909086676,999”, private string GetStrings(string str,int type=0) { IList<strin ...
  • Swagger一個優秀的Api介面文檔生成工具。Swagger可以可以動態生成Api介面文檔,有效的降低前後端人員關於Api介面的溝通成本,促進項目高效開發。 1、使用NuGet安裝最新的包:Swashbuckle.AspNetCore。 2、編輯項目文件(NetCoreTemplate.Web.c ...
  • 2020 年 7 月 30 日, 由.NET基金會和微軟 將舉辦一個線上和為期一天的活動,包括 微軟 .NET 團隊的演講者以及社區的演講者。本次線上大會 專註.NET框架構建微服務,演講者分享構建和部署雲原生應用程式的最佳實踐、模式、提示和技巧。有關更多信息和隨時瞭解情況:https://focu... ...
  • #abp框架Excel導出——基於vue #1.技術棧 ##1.1 前端採用vue,官方提供 UI套件用的是iview ##1.2 後臺是abp——aspnetboilerplate 即abp v1,https://github.com/aspnetboilerplate/aspnetboilerp ...
  • 前言 本文的文字及圖片來源於網路,僅供學習、交流使用,不具有任何商業用途,版權歸原作者所有,如有問題請及時聯繫我們以作處理。 作者:碧茂大數據 PS:如有需要Python學習資料的小伙伴可以加下方的群去找免費管理員領取 input()輸入 Python提供了 input() 內置函數從標準輸入讀入一 ...
  • 從12年到20年,python以肉眼可見的趨勢超過了java,成為了當今It界人人皆知的編程語言。 python為什麼這麼火? 網路編程語言搜索指數 適合初學者 Python具有語法簡單、語句清晰的特點,這就讓初學者在學習階段可以把精力集中在編程對象和思維方法上。 大佬都在用 Google,YouT ...
  • 在社會上存在一種普遍的對培訓機構的學生一種歧視的現象,具體表現在,比如:當你去公司面試的時候,一旦你說了你是培訓機構出來的,那麼基本上你就涼了,那麼你瞞著不說,然後又通過了面試成功入職,但是以後一旦在公司被髮現有培訓經歷,可能會面臨被降薪,甚至被辭退,培訓機構出來的學生,在用人單位眼裡就是能力低下的 ...
  • from typing import List# 這道題看了大佬寫的代碼,經過自己的理解寫出來了。# 從最外圍的四周找有沒有為O的,如果有的話就進入深搜函數,然後深搜遍歷# 判斷上下左右的位置是否為Oclass Solution: def solve(self, board: List[List[s ...
  • import requests; import re; import os; # 1.請求網頁 header = { "user-agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, li ...
  • import requests; import re; import os; import parsel; 1.請求網頁 header = { "user-agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537. ...