开发者

HttpRequest and javascript - can you mimic actual browser behavior with regards to javascript with C#?

I'm posting some form values to a form using HttpWebRequest. The problem is that the post behaves differently depending on javascript function call results. Javascript runs on the client browser, so I'm doubting I can get around this problem, but does anyone know a way of mimic-ing a browser's behavior with regard to javascript from C# code?

Alternatively, is there a way for me to manipulate Internet Explorer to get and post values to different U开发者_C百科RLs from a C# Windows Service? Can it be done with a WinForms app?


Yes, you can automate browsers from any .NET application using an automation framework:

  • Selenium
  • WatiN


You can run Javascript in cscript.exe. You don't get the browser API, but you can use Javascript libraries, can do AJAX, XMLHTTPRequest, etc.

You can also use a MSHTML control within a C# app to retrieve a web page. That is effectivedly embedding IE into your app, including running browser-side Javascript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜