CefSharp 获取POST(AJAX)、GET消息返回值(request)

    CefSharp作为专门为爬虫工具开发的库比Selenium这种开发目的是页面测试工具然后用来做爬虫的工具要贴心得多。我们操作网页的时候发送或者做了某个动作提交表单之后需要知道我们的动作或者提交是否成功,因为有的页面会因为网络延迟问题提交失败,需要准确的获取到发送消息后服务器的返回值,如果直接通过页面的弹窗获取发送消息后的结果会非常麻烦,有时候一个消息发送后会产生多种不同的返回结果,可能提交成功,可能提交失败,可能消息超时等等,如果能够直接获取到发送消息的Request,无疑会大大方便我们判断。

例如这是点击百度搜索框时产生的GET消息的返回值:

    CefSharp贴心的为开发者提供了网页运行的不同阶段的回调函数,类似于VUE前端框架的钩子函数。CefSharp允许开发者在POST或GET消息发送时修改提交的参数也就是postData,还可以拦截修改图片,JS文件,CSS样式等等,这篇文章只是记录如何获取GET或者POST消息提交后直接获取JSON、XML、HTML数据。

这些自定义功能都基于IResourceRequestHandler类,首先我们要创建一个新的类继承重写这个类中的方法。

public class ResourceRequestHandler : IResourceRequestHandler{/// <summary>/// Called on the CEF IO thread before a resource request is loaded. To optionally filter cookies for the request return a/// <see cref="ICookieAccessFilter"/> object./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - can be modified in this callback.</param>/// <returns>To optionally filter cookies for the request return a ICookieAccessFilter instance otherwise return null.</returns>ICookieAccessFilter IResourceRequestHandler.GetCookieAccessFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return GetCookieAccessFilter(chromiumWebBrowser, browser, frame, request);}/// <summary>/// Called on the CEF IO thread before a resource request is loaded. To optionally filter cookies for the request return a/// <see cref="ICookieAccessFilter"/> object./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - can be modified in this callback.</param>/// <returns>To optionally filter cookies for the request return a ICookieAccessFilter instance otherwise return null.</returns>protected virtual ICookieAccessFilter GetCookieAccessFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return null;}/// <summary>/// Called on the CEF IO thread before a resource is loaded. To specify a handler for the resource return a/// <see cref="IResourceHandler"/> object./// </summary>/// <param name="chromiumWebBrowser">The browser UI control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <returns>/// To allow the resource to load using the default network loader return null otherwise return an instance of/// <see cref="IResourceHandler"/> with a valid stream./// </returns>IResourceHandler IResourceRequestHandler.GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return GetResourceHandler(chromiumWebBrowser, browser, frame, request);}/// <summary>/// Called on the CEF IO thread before a resource is loaded. To specify a handler for the resource return a/// <see cref="IResourceHandler"/> object./// </summary>/// <param name="chromiumWebBrowser">The browser UI control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <returns>/// To allow the resource to load using the default network loader return null otherwise return an instance of/// <see cref="IResourceHandler"/> with a valid stream./// </returns>protected virtual IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return null;}/// <summary>Called on the CEF IO thread to optionally filter resource response content.</summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <returns>Return an IResponseFilter to intercept this response, otherwise return null.</returns>IResponseFilter IResourceRequestHandler.GetResourceResponseFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response){return GetResourceResponseFilter(chromiumWebBrowser, browser, frame, request, response);}/// <summary>Called on the CEF IO thread to optionally filter resource response content.</summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <returns>Return an IResponseFilter to intercept this response, otherwise return null.</returns>protected virtual IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response){return null;}/// <summary>/// Called on the CEF IO thread before a resource request is loaded. To redirect or change the resource load optionally modify/// <paramref name="request"/>. Modification of the request URL will be treated as a redirect./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - can be modified in this callback.</param>/// <param name="callback">Callback interface used for asynchronous continuation of url requests.</param>/// <returns>/// Return <see cref="CefReturnValue.Continue"/> to continue the request immediately. Return/// <see cref="CefReturnValue.ContinueAsync"/> and call <see cref="IRequestCallback.Continue"/> or/// <see cref="IRequestCallback.Cancel"/> at a later time to continue or the cancel the request asynchronously. Return/// <see cref="CefReturnValue.Cancel"/> to cancel the request immediately./// </returns>CefReturnValue IResourceRequestHandler.OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){return OnBeforeResourceLoad(chromiumWebBrowser, browser, frame, request, callback);}/// <summary>/// Called on the CEF IO thread before a resource request is loaded. To redirect or change the resource load optionally modify/// <paramref name="request"/>. Modification of the request URL will be treated as a redirect./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - can be modified in this callback.</param>/// <param name="callback">Callback interface used for asynchronous continuation of url requests.</param>/// <returns>/// Return <see cref="CefReturnValue.Continue"/> to continue the request immediately. Return/// <see cref="CefReturnValue.ContinueAsync"/> and call <see cref="IRequestCallback.Continue"/> or/// <see cref="IRequestCallback.Cancel"/> at a later time to continue or the cancel the request asynchronously. Return/// <see cref="CefReturnValue.Cancel"/> to cancel the request immediately./// </returns>protected virtual CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){return CefReturnValue.Continue;}/// <summary>/// Called on the CEF UI thread to handle requests for URLs with an unknown protocol component. SECURITY WARNING: YOU SHOULD USE/// THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <returns>/// return to true to attempt execution via the registered OS protocol handler, if any. Otherwise return false./// </returns>bool IResourceRequestHandler.OnProtocolExecution(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return OnProtocolExecution(chromiumWebBrowser, browser, frame, request);}/// <summary>/// Called on the CEF UI thread to handle requests for URLs with an unknown protocol component. SECURITY WARNING: YOU SHOULD USE/// THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <returns>/// return to true to attempt execution via the registered OS protocol handler, if any. Otherwise return false./// </returns>protected virtual bool OnProtocolExecution(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request){return false;}/// <summary>/// Called on the CEF IO thread when a resource load has completed. This method will be called for all requests, including/// requests that are aborted due to CEF shutdown or destruction of the associated browser. In cases where the associated browser/// is destroyed this callback may arrive after the <see cref="ILifeSpanHandler.OnBeforeClose"/> callback for that browser. The/// <see cref="IFrame.IsValid"/> method can be used to test for this situation, and care/// should be taken not to call <paramref name="browser"/> or <paramref name="frame"/> methods that modify state (like LoadURL,/// SendProcessMessage, etc.) if the frame is invalid./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <param name="status">indicates the load completion status.</param>/// <param name="receivedContentLength">is the number of response bytes actually read.</param>void IResourceRequestHandler.OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength){OnResourceLoadComplete(chromiumWebBrowser, browser, frame, request, response, status, receivedContentLength);}/// <summary>/// Called on the CEF IO thread when a resource load has completed. This method will be called for all requests, including/// requests that are aborted due to CEF shutdown or destruction of the associated browser. In cases where the associated browser/// is destroyed this callback may arrive after the <see cref="ILifeSpanHandler.OnBeforeClose"/> callback for that browser. The/// <see cref="IFrame.IsValid"/> method can be used to test for this situation, and care/// should be taken not to call <paramref name="browser"/> or <paramref name="frame"/> methods that modify state (like LoadURL,/// SendProcessMessage, etc.) if the frame is invalid./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <param name="status">indicates the load completion status.</param>/// <param name="receivedContentLength">is the number of response bytes actually read.</param>protected virtual void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength){}/// <summary>/// Called on the CEF IO thread when a resource load is redirected. The <paramref name="request"/> parameter will contain the old/// URL and other request-related information. The <paramref name="response"/> parameter will contain the response that resulted/// in the redirect. The <paramref name="newUrl"/> parameter will contain the new URL and can be changed if desired./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <param name="newUrl">[in,out] the new URL and can be changed if desired.</param>void IResourceRequestHandler.OnResourceRedirect(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl){OnResourceRedirect(chromiumWebBrowser, browser, frame, request, response, ref newUrl);}/// <summary>/// Called on the CEF IO thread when a resource load is redirected. The <paramref name="request"/> parameter will contain the old/// URL and other request-related information. The <paramref name="response"/> parameter will contain the response that resulted/// in the redirect. The <paramref name="newUrl"/> parameter will contain the new URL and can be changed if desired./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object - cannot be modified in this callback.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <param name="newUrl">[in,out] the new URL and can be changed if desired.</param>protected virtual void OnResourceRedirect(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl){}/// <summary>/// Called on the CEF IO thread when a resource response is received. To allow the resource load to proceed without modification/// return false. To redirect or retry the resource load optionally modify <paramref name="request"/> and return true./// Modification of the request URL will be treated as a redirect. Requests handled using the default network loader cannot be/// redirected in this callback./// /// WARNING: Redirecting using this method is deprecated. Use OnBeforeResourceLoad or GetResourceHandler to perform redirects./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <returns>/// To allow the resource load to proceed without modification return false. To redirect or retry the resource load optionally/// modify <paramref name="request"/> and return true. Modification of the request URL will be treated as a redirect. Requests/// handled using the default network loader cannot be redirected in this callback./// </returns>bool IResourceRequestHandler.OnResourceResponse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response){return OnResourceResponse(chromiumWebBrowser, browser, frame, request, response);}/// <summary>/// Called on the CEF IO thread when a resource response is received. To allow the resource load to proceed without modification/// return false. To redirect or retry the resource load optionally modify <paramref name="request"/> and return true./// Modification of the request URL will be treated as a redirect. Requests handled using the default network loader cannot be/// redirected in this callback./// /// WARNING: Redirecting using this method is deprecated. Use OnBeforeResourceLoad or GetResourceHandler to perform redirects./// </summary>/// <param name="chromiumWebBrowser">The ChromiumWebBrowser control.</param>/// <param name="browser">the browser object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="frame">the frame object - may be null if originating from ServiceWorker or CefURLRequest.</param>/// <param name="request">the request object.</param>/// <param name="response">the response object - cannot be modified in this callback.</param>/// <returns>/// To allow the resource load to proceed without modification return false. To redirect or retry the resource load optionally/// modify <paramref name="request"/> and return true. Modification of the request URL will be treated as a redirect. Requests/// handled using the default network loader cannot be redirected in this callback./// </returns>protected virtual bool OnResourceResponse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response){return false;}/// <summary>/// Called when the unamanged resource is freed./// Unmanaged resources are ref counted and freed when/// the last reference is released, this works differently/// to .Net garbage collection./// </summary>protected virtual void Dispose(){}void IDisposable.Dispose(){Dispose();}}

然后获取消息发送后的返回值则是在IResponseFilter类的方法中接收,也新建一个类继承IResponseFilter类。

public class TestJsonFilter : IResponseFilter{public List<byte> DataAll = new List<byte>();public FilterStatus Filter(System.IO.Stream dataIn, out long dataInRead, System.IO.Stream dataOut, out long dataOutWritten){try{if (dataIn == null || dataIn.Length == 0){dataInRead = 0;dataOutWritten = 0;return FilterStatus.Done;}dataInRead = dataIn.Length;dataOutWritten = Math.Min(dataInRead, dataOut.Length);dataIn.CopyTo(dataOut);dataIn.Seek(0, SeekOrigin.Begin);byte[] bs = new byte[dataIn.Length];dataIn.Read(bs, 0, bs.Length);DataAll.AddRange(bs);dataInRead = dataIn.Length;dataOutWritten = dataIn.Length;return FilterStatus.NeedMoreData;}catch (Exception ex){dataInRead = dataIn.Length;dataOutWritten = dataIn.Length;return FilterStatus.Done;}}public bool InitFilter(){return true;}public void Dispose(){}}

再创建一个类用于配合读取返回值。

    public class FilterManager{private static Dictionary<string, IResponseFilter> dataList = new Dictionary<string, IResponseFilter>();public static IResponseFilter CreateFilter(string guid){lock (dataList){var filter = new TestJsonFilter();dataList.Add(guid, filter);return filter;}}public static IResponseFilter GetFileter(string guid){lock (dataList){return dataList[guid];}}}

然后重写IResponseFilter、OnResourceLoadComplete两个接口,在OnResourceLoadComplete接口中就能接收返回值了。返回值会返回到函数的request参数下,此参数是一个结构体,可以自行在 if (request.Url.ToLower().Contains("sugrec")) 这一句上下断点查看结构体的内容,然后自行加判断来过滤返回值,这里鄙人先判断发送类型为GET消息,然后再根据发送消息URL里的关键字来过滤返回值,最后显示到WinForm窗口程序绑定的控制台窗口里。

    public class WinFormResourceRequestHandler : ResourceRequestHandler{protected override IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response){var filter = FilterManager.CreateFilter(request.Identifier.ToString());return filter;}protected override void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength){if (request.Method == "GET"){//先指定消息类型POST或者GETif (request.Url.ToLower().Contains("sugrec")){//以URL为过滤条件var filter = FilterManager.GetFileter(request.Identifier.ToString()) as TestJsonFilter;UTF8Encoding encoding = new UTF8Encoding();//这里截获返回的数据var data = encoding.GetString(filter.DataAll.ToArray());System.Console.WriteLine("742行:" + data);}}}}public class WinFormsRequestHandler : RequestHandler{protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling){//NOTE: In most cases you examine the request.Url and only handle requests you are interested inif (request.Url.ToLower().Contains("login".ToLower())){using (var postData = request.PostData){if (postData != null){var elements = postData.Elements;var charSet = request.GetCharSet();foreach (var element in elements){if (element.Type == PostDataElementType.Bytes){var body = element.GetBody(charSet);}}}}}return new WinFormResourceRequestHandler();}}

运行程序后:

如何运用这个自定义的类呢?

using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using CefSharp.Handler;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text.RegularExpressions;
using System.Security.Cryptography.X509Certificates;
using System.IO;public partial class Form1 : Form
{ChromiumWebBrowser different;[DllImport("kernel32.dll")]public static extern bool AllocConsole();[DllImport("kernel32.dll")]public static extern bool FreeConsole();public Form1(){InitializeComponent();AllocConsole(); //关联一个控制台窗口用于显示信息}private void Form1_Load(object sender, EventArgs e){CefSettings settings = new CefSettings();settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Know";//设置cookie存储目录 C:\Users\×××(系统用户名)\AppData\Local\KnowCef.Initialize(settings);//初始化Cef组件different = new ChromiumWebBrowser("https://www.baidu.com");different.RequestHandler = new WinFormsRequestHandler();//应用拦截规则different.LifeSpanHandler = new CefLifeSpanHandler();//让新页面在当前页面打开different.BrowserSettings = new BrowserSettings(){WebGl = CefState.Enabled,ImageLoading = CefState.Enabled,RemoteFonts = CefState.Enabled,AcceptLanguageList = "zh-CN"};tableLayoutPanel1.Controls.Add(different, 0, 1);//把浏览器空间加入布局容器}private void Form1_FormClosing(object sender, FormClosingEventArgs e){//窗口关闭前 回调函数FreeConsole();//释放关联的控制台,不然会报错}}

参考资料:https://www.cnblogs.com/heifengwll/p/13277232.html

如何拦截替换页面资源,JS,CSS等:CefSharp请求资源拦截及自定义处理-腾讯云开发者社区-腾讯云

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/215209.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

十五、机器学习进阶知识:K-Means聚类算法

文章目录 1、聚类概述2、K-Means聚类算法原理3、K-Means聚类实现3.1 基于SKlearn实现K-Means聚类3.2 自编写方式实现K-Means聚类 4、算法不足与解决思路4.1 存在的问题4.2 常见K值确定方法4.3 算法评估优化思路 1、聚类概述 聚类&#xff08;Clustering&#xff09;是指将不同…

正则表达式详细讲解

目录 一、正则表达式概念 二、八元素 1、普通字符&#xff1a; 2、元字符&#xff1a; 3、通配符 .&#xff1a; 4、字符类 []&#xff1a; 5、量词&#xff1a; 6、锚点 ^ 和 $&#xff1a; 7、捕获组 ()&#xff1a; 8、转义字符 \&#xff1a; 三、日常使用的正则…

股市复苏中的明懿金汇:抓住新机遇

2023年对于明懿金汇来说是充满挑战与机遇的一年。面对复杂多变的市场环境&#xff0c;明懿金汇展现了其对市场趋势的敏锐洞察和卓越的策略适应能力。以下是该公司在2023年的主要投资策略和市场适应方式的详细分析。 随着2023年中国股市迎来反弹&#xff0c;明懿金汇迅速调整了…

Linux网络——高级IO

目录 一.五种IO模型 1.阻塞式IO 2.非阻塞式IO 3.信号驱动IO 4.多路转接IO&#xff1a; 5.异步IO 二.同步通信 vs 异步通信 三.设置非阻塞IO 1.阻塞 vs 非阻塞 2.非阻塞IO 3.实现函数SetNoBlock 四.I/O多路转接之select 1.初识select 2.select函数原型 3.socket就绪…

国内大厂机器人赛道产品

大疆 大疆无人机自然不必说&#xff0c;除此之外大疆搞机甲大师&#xff0c;教育机器人。 字节 当前字节在机器人领域只是初步探索阶段&#xff0c;目前尚未发布相关产品&#xff08;截止至23.12&#xff09;。 管理层想法&#xff1a; 跟已有业务做结合&#xff0c;服务好…

Axure->Axure安装,Axure菜单栏和工具栏功能介绍,页面及概要区

Axure安装Axure菜单栏和工具栏功能介绍&#xff0c;页面及概要区 1.Axure安装 即时设计 - 可实时协作的专业 UI 设计工具 (js.design) 点击上方下载安装⬆ 打开软件点击帮助->管理授权-> 被授权人 Axure 授权密钥:gjqpIxSSUUqFwPoZPi8XwBBhRE2VNmOQsrord0JqShk4QCXxrw6…

CLion安装与配置教程

目录 一、下载并安装CLion1、下载1、官网&#xff1a;2、注意&#xff1a; 2、安装1、下载完成后&#xff0c;直接点击安装包安装&#xff0c;即可。2、开始安装&#xff0c;然后下一步3、可以在此处自定义地址&#xff0c;然后下一步4、根据系统版本选择&#xff0c;然后下一步…

LeetCode5.最长回文子串

昨天和之前打比赛的队友聊天&#xff0c;他说他面百度面到这道算法题&#xff0c;然后他用暴力法解的&#xff0c;面试官让他优化他没优化出来&#xff0c;这道题我之前没写过&#xff0c;我就想看看我能不能用效率高一点的方法把它做出来&#xff0c;我一开始就在想用递归或者…

31、卷积 - 参数 dilation 以及空洞卷积

在卷积算法中,还有一个不常见的参数叫做dilation(中文:膨胀)。 很多同学可能没听说过这个参数,下面看看这个参数有什么作用,用来控制什么的。 我们还是放这个经典的卷积运算图,图中是看不出 dilation 这个参数的存在的。 如果再换一张图呢,发现两图的区别了吗? 没错…

设计模式篇---代理模式

文章目录 概念结构实例静态代理动态代理 总结 概念 代理模式&#xff1a;给某一个对象提供一个代理或占位符&#xff0c;并由代理对象来控制对原对象的访问。 比如我们想从其他国家买东西&#xff0c;但我们无法直接联系外国的商家&#xff0c;可以找代理商&#xff0c;让他们…

学习人工智能-基础篇

背景 随着大模型的火爆&#xff0c;人工智能再次被推到高潮&#xff0c;其实它在众多行业领域已经落地很多应用&#xff0c;并给社会带来了巨大的经济价值。其中包括互联网、教育、金融、医疗、交通、物流等等。在测试领域也有一些落地的案例&#xff0c;作为测试人员&#xf…

机器学习-逻辑回归

一、引言 逻辑回归&#xff08;Logistic Regression&#xff09;是一种广泛应用于分类问题的监督学习算法。尽管名字中含有“回归”二字&#xff0c;但这并不意味着它用于解决回归问题。相反&#xff0c;逻辑回归专注于解决二元或多元分类问题&#xff0c;如邮件是垃圾邮件还是…

2023-12学习笔记

1.NonNull要手动写无参构造器 这是一个我今天研究了很久的问题&#xff0c;开始不知道原因是在这里&#xff0c;还在那想是不是Data覆盖了无参构造&#xff0c;结果当然不是。先说下解决历程 1.问题起因 通过RequestBody接收前端报文的时候报错&#xff0c;大致是说我构造方…

热电厂发电机组常见故障及预测性维护方法

热电厂的发电机组是关键的能源生产设备&#xff0c;在电力供应中扮演着关键角色。但经过长期运行和高负荷工作&#xff0c;一旦发生故障&#xff0c;可能导致停机、设备损坏甚至引发严重事故。因此&#xff0c;实施有效的预测性维护方法对于确保发电机组的稳定运行至关重要。本…

Python从入门到精通五:Python数据容器

数据容器入门 为什么学习数据容器 思考一个问题&#xff1a;如果我想要在程序中&#xff0c;记录5名学生的信息&#xff0c;如姓名。 如何做呢&#xff1f; 学习数据容器&#xff0c;就是为了批量存储或批量使用多份数据 Python中的数据容器&#xff1a; 一种可以容纳多份…

gitee对接使用

1.创建一个文件夹 2.进入Gitee接受对方项目编辑 3.打开终端初始化一开始创建的文件夹 git init 3.1打开终端 3.2输入git.init 4.克隆对方的项目 4.1进入Gitee复制对方项目的路径 4.2在编辑器终端内克隆对方项目 git clone 网址 如此你的编辑器就会出现对方的项目 …

使用pe安装windows操作系统

一、系统安装前准备工作&#xff0c;制作系统盘 &#xff08;1&#xff09;拷贝电脑上的资料 &#xff08;2&#xff09;准备一个至少8G的U盘 &#xff08;3&#xff09;下载windows镜像文件及pe软件 通过百度网盘可下载下列软件及镜像 windows镜像文件&#xff08;百度网盘…

如何通过SPI控制Peregrine的数控衰减器

概要 Peregrine的数控衰减器PE4312是6位射频数字步进衰减器(DSA,Digital Step Attenuator)工作频率覆盖1MHz~4GHz,插入损耗2dB左右,衰减步进0.5dB,最大衰减量为31.5dB,高达59dBm的IIP3提供了良好的动态性能,切换时间0.5微秒,供电电源2.3V~5.5V,逻辑控制兼容1.8V,20…

容器重启后,Conda文件完整保存(虚拟环境、库包),如何重新安装conda并迁移之前的虚拟环境

Vim安装 容器重启后默认是vi&#xff0c;升级vim&#xff0c;执行命令 apt install -y vim安装 Anaconda 1. 下载Anaconda 其他版本请查看Anaconda官方库 wget https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-2023.03-1-Linux-x86_64.sh --no-check-certificate…

HarmonyOS4.0从零开始的开发教程09页签切换

HarmonyOS&#xff08;七&#xff09;页签切换 List组件和Grid组件的使用 Tabs组件的使用 概述 在我们常用的应用中&#xff0c;经常会有视图内容切换的场景&#xff0c;来展示更加丰富的内容。比如下面这个页面&#xff0c;点击底部的页签的选项&#xff0c;可以实现“首页…