代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using Gecko;
namespace RBrowser
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
InitCef();
InitFireFox();
Application.Run(new FrmMain());
}
private static void InitCef()
{
var setting = new CefSettings
{
Locale = "zh-CN",
AcceptLanguageList = "zh-CN,zh;q=0.8",
PersistSessionCookies = true
};
// 设置是否使用GPU
setting.CefCommandLineArgs.Add("disable-gpu", "1");
// 设置是否使用代理服务
setting.CefCommandLineArgs.Add("no-proxy-server", "1");
//Cookies
string cachePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"\Chrome_Cache";
if (Directory.Exists(cachePath))
{
Directory.Delete(cachePath, true);
}
Directory.CreateDirectory(cachePath);
setting.CachePath = cachePath;
setting.PersistSessionCookies = true;
// 设置是否启动js交互,假如需要原生与js方法互调,则需要设置为true
CefSharpSettings.LegacyJavascriptBindingEnabled = true;
// 初始化
Cef.Initialize(setting, performDependencyCheck: true, browserProcessHandler: null);
}
private static void InitFireFox()
{
Xpcom.Initialize("FireFox");
GeckoPreferences.User["intl.accept_languages"] = "zh-CN,zh;q=0.9,en;q=0.8";
string cachePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"\FireFox_Cache";
if (Directory.Exists(cachePath))
{
Directory.Delete(cachePath, true);
}
Directory.CreateDirectory(cachePath);
Gecko.Xpcom.ProfileDirectory = cachePath;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。