1
我正在研究一个项目,我想使用Chromium Web浏览器并能够读取通常通过DevTools“网络”选项卡来的数据。所以基本上我真正需要的是URL和状态码(404,200,50x等)。CEFSharp - 阅读网络响应
我有一切正常工作的ChromiumWebBrowser部分,因为这工作完美,但我似乎无法弄清楚如何获得网络数据的细节。
我发现这在github问题部分,但我真的不明白如何实现它。 https://github.com/cefsharp/CefSharp/issues/1379
任何帮助将不胜感激。
这里是我迄今为止...
private ChromiumWebBrowser _wb;
public MainForm()
{
var cefsettings = new CefSettings { CachePath = "cache" };
cefsettings.CachePath = "cache";
if (cefsettings.CefCommandLineArgs.ContainsKey("enable-system-flash"))
{
string flashValue;
cefsettings.CefCommandLineArgs.TryGetValue("enable-system-flash", out flashValue);
if (flashValue != "1")
{
Debug.WriteLine("Flash Might Be Disabled For Chromium Web Browser");
}
}
else
{
cefsettings.CefCommandLineArgs.Add("enable-system-flash", "1");
}
//TODO: Get the latest version version folder
cefsettings.CefCommandLineArgs.Add("ppapi-flash-path","C:\\program Files (x86)\\Google\\Chrome\\Application\\51.0.2704.103\\PepperFlash\\pepflashplayer.dll");
Cef.Initialize(cefsettings);
InitializeComponent();
_wb = new ChromiumWebBrowser("http://youtube.com/")
{
Dock = DockStyle.Fill,
Location = new System.Drawing.Point(0, 22),
MinimumSize = new System.Drawing.Size(20, 20),
Size = new System.Drawing.Size(1280, 900),
TabIndex = 8
};
//Add ChromiumWebBrowser to the Browser Panel
pnlBrowser.Controls.Add(_wb);
}
执行'IRequestHandler'并调用'_wb.RequestHandler = new CustomRequestHandler()'。 – amaitland
@amaitland感谢您的评论。想出它前几天忘了发布我的回答:) – BinaryNexus