如何使用c#winform调用网站的js代码 [英] how to use c# winform call website's js code

查看:99
本文介绍了如何使用c#winform调用网站的js代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <div class="wrap" style="display:none">
<a href="java<!-- no -->script:loginrecommend();" class="btn-login t-hd">Start Game</a>
 </div>





当我浏览其他人的网站时,我查看网页来源,我想使用我的c#winform运行javascript:loginrecommend(),以便自动登录,也许使用cookie更好。

我该怎么办?



when i browser other people's website,i View the webpage source ,i want to use my c# winform to run the javascript:loginrecommend(),so that auto to login,maybe use cookie is better.
how can i do?

推荐答案

请看我对这个问题的评论,至少不清楚。从浏览器外部调用HTML页面的JavaScript代码的想法根本没有意义。



基本上,你应该在代码中完成所有操作,同样的事情像浏览器一样,包括身份验证。您可以使用类 System.Net.HttpWebRequest

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest。 credentials.aspx [ ^ ]。



请查看我过去的答案:

从网页获取特定数据 [ ^ ],

如何从其他网站获取数据 [ ^ ]。



您可以找到许多带身份验证的代码示例,例如:

http://stackoverflow.com/questions/1076015/handling-authentication-with -httpwebrequest-net [ ^ ],

HttpWebRequest凭据身份验证 [ ^ ]。



你可以找到更多: http://www.codeproject.com/search.aspx?q=%28HttpWebRequest+OR+HttpRequest%29+authentication&doctypeid = 5 [ ^ ]。



-SA
Please see my comments to the question, which is at least not clear. The idea to call JavaScript code of the HTML page from outside of the browser simply makes no sense.

Basically, you should do it all in your code, the same thing as the browser does, including authentication. You can use the class System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx[^].

Please see my past answers:
get specific data from web page[^],
How to get the data from another site[^].

You can find many code samples with authentication, such as:
http://stackoverflow.com/questions/1076015/handling-authentication-with-httpwebrequest-net[^],
HttpWebRequest Credential Authentication[^].

You can find a lot more: http://www.codeproject.com/search.aspx?q=%28HttpWebRequest+OR+HttpRequest%29+authentication&doctypeid=5[^].

—SA


这篇关于如何使用c#winform调用网站的js代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆