DragonWar% 2015-05-02 08:13 采纳率: 0%
浏览 27

C#/。NET中的网站“主管”

I'm not sure what the technical name for what I'm looking for is, but this is what I'm trying to achieve:

I need to write a "client" for a specific website which uses Ajax/XHR for communication with the server.

My approach is to make a custom web browser that will run the JavaScript in the background, and I can show all the relevant information to the user. My first thought was to use hidden WebBrowser, however I'm not sure if it can achieve all the following:

  • Denying requests (so that unnecessary content doesn't load)
  • Inspecting (and possibly editing) XHR requests and responses
  • Making custom JavaScript calls (using javascript: quasi-protocol is ok)
  • Inspecting HTML elements' event listeners (so that I can call them)

Basically, I want functionality similar to that of Chrome's Developer Tools, in C#.

What's the easiest way of doing so, since my current idea is to use WebBrowser through a custom proxy, with hardcoded event listeners (manually found, hoping names don't change soon)?

  • 写回答

1条回答 默认 最新

  • weixin_33728708 2015-05-02 08:43
    关注

    If you truly want to use C# and Chrome, go for CefSharp:

    which is bindings for .NET and Chromium browser.

    I think it could be a lot easier to use Electron or nw.js, but these would require you code in javascript, which of cause also will make custom javascript calls easier.

    Side note: The new Visual Studio Code is actually built with Electron, so even microsoft uses that for doing javascript/web technology based apps.

    评论

报告相同问题?