简体   繁体   English

从应用程序加载网页,然后单击该页面上的链接?

[英]Loading a webpage from an application and then clicking a link on that page?

I'm writing an app which should load a website.我正在编写一个应该加载网站的应用程序。 After the website is loaded, I have to fire up a 2nd command to the web page, which is kind of Javascript scriptlet.网站加载后,我必须向网页发出第二个命令,这是一种 Javascript 脚本。

I did this manually in my browser and in generally it seems to work fine.我在浏览器中手动执行此操作,通常它似乎工作正常。 They way I did it manually was I created two shortcuts in my browser:我手动完成的方式是我在浏览器中创建了两个快捷方式:

  1. the URL to this website (eg http://www.example.net/123456-e.aspx )此网站的 URL(例如http://www.example.net/123456-e.aspx
  2. the shortcut to a Scriptlet which calls a function on this website (eg javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')) .调用此网站上的函数的 Scriptlet 的快捷方式(例如javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5',''))

I first click the URL shortcut and after its loaded, I fire up the 2nd shortcut.我首先单击 URL 快捷方式,加载后,我启动了第二个快捷方式。

But how can I do this in a C# application?但是如何在 C# 应用程序中执行此操作?


But, what I'm trying to do is quite the opposite I think.但是,我正在尝试做的事情与我的想法完全相反。

I'd like to SEND a _postBack to an existing site.我想将_postBack发送到现有站点。 I'm not writing my own site which contains a postBack control!我不是在写我自己的包含 postBack 控件的站点!

Let me explain a little in detail...让我稍微详细解释一下......

the site I'm loading in my app is an existing ASPX site in the web.我在我的应用程序中加载的站点是网络中现有的 ASPX 站点。 In this site, you'll find several _doPostback entries and in a browser, the postBack event (when I hit it manually within a bookmark/shortcut) will be send back and has its desired result (in this case, its assigning "5 stars" to tell everybody, that something is supergood ;-).在此站点中,您会找到几个_doPostback条目,并且在浏览器中,postBack 事件(当我在书签/快捷方式中手动点击它时)将被发回并获得所需的结果(在这种情况下,它的分配为“5 星” " 告诉大家,有些东西非常好;-)。

So, what I'd like to do is to write my C# App which will send this _postBack command every time I hit the OK button or some other events.所以,我想要做的是编写我的 C# 应用程序,它会在我每次点击“确定”按钮或其他一些事件时发送这个_postBack命令。 Just as it is with my link above就像我上面的链接一样

"javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')"

This is the bookmark I have on my browsers bookmark panel - a shortcut!这是我在浏览器书签面板上的书签 - 一个快捷方式!

.... Just to be honest, its a kind of cheat, which will do an automatic voting on an external site... .... 老实说,这是一种作弊,会在外部站点上进行自动投票......

My prob is now,... how can I send this _postBack straight to the site, to increase my stars?我现在的问题是,...我怎样才能将此_postBack直接发送到网站,以增加我的星星?

I am not sure what exactly you are trying to achieve, The code which you are seeing ( _doPastBack(..) ) is actually going to invoke a server method (code in your codebehind of that page).我不确定您到底要实现什么,您看到的代码( _doPastBack(..) )实际上是要调用服务器方法(该页面的代码隐藏中的代码)。

You can create a webpage and have an iframe and load your first page in that.The user will be able to click on any of the button and invoke the corresponding server code if there is one attached.您可以创建一个网页并拥有一个 iframe 并在其中加载您的第一个页面。用户将能够单击任何按钮并调用相应的服务器代码(如果附加了一个)。

<html>
<body>
  <iframe src="http://www.example.net/123456-e.aspx"></iframe>
</body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM