如何填写,并在使用Windows应用程序中的第三方网站提交网页表单?(How to fill and submit a web form on a third party website using windows application)

   IT问题网   2018-01-19 00:00:00

问 题

我做的一个项目中,我必须做出一个windows应用程序,它可以从用户处获得一个网址的文本框。现在,当用户press继续按钮,应用程序应该打开url在webbrowser控件,并填写包含用户id和放大器,页面的表单;密码文本框,并通过该网页上的登录按钮提交。现在,我的应用程序应该显示的下一个页面中的webbrowser控件的用户。

我可以通过我的c#code。打开网址在应用程序的web浏览器的控制,但我不能算出它是如何找到用户id和放大器;这是在我的应用程序的webbrowser控件当前打开的网页上pasword文本框,如何填补他们,如何找到登录按钮和放大器;如何通过我的c#code。单击它。

解决方案

有关这一点,你将不得不寻找到第三方网站的网页源代码,找到用户名,密码文本框的id,并提交按钮。 (如果你提供一个链接,我会帮你了解一下)。然后用这个code:

//添加的引用microsoft.mshtml在解决方案资源管理
使用mshtml;

私人shdocvw.webbrowser_v1 web_v1;

form1_load的()
{
web_v1 =(shdocvw.webbrowser_v1)webbrowser1.activexinstance;
}

webbrowser1_document_complete()
{
如果(webbrowser1.readystate == webbrowserreadystate.complete)
{
如果(webbrowser1.url.tostring()=="yourloginsite.com")
{
尝试
{
htmldocument的通=新htmldocument的();
通过=(htmldocument的)web_v1.document;
htmlinputelement传递窗=(htmlinputelement)pass.all.item("passidthatyoufoundinsource",0);
passbox.value ="你的密码";
htmldocument的日志=新htmldocument的();
登录=(htmldocument的)web_v1.document;
htmlinputelement logbox =(htmlinputelement)log.all.item("loginidfrompagesource",0);
logbox.value ="yourlogin";
htmlinputelement提交=(htmlinputelement)pass.all.item("submitbuttonidfrompagesource",0);
submit.click();
}
抓住 { }
}
}
}
 

标签:如何填写使用应用程序中的第三网站提交网页表单



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

如何C#程序使用任何版本的一个COM DLL?(How can a C# program use a COM dll of any version)

problem this question is a sequel of this que ...

如何使用单位工作的领域层(How to use Unit of Work in Domain Layer)

problem i'm trying to use the unit of work pa ...

创建图像掩码(Create Image Mask)

problem the user provides my app an image, from which the ...

我如何通过可变参数从托管到非托管与C ++ / CLI包装?(How do I pass variable arguments from managed to unmanaged with a C++/CLI Wrapper)

problem to implement a params(variable argume ...

如何强制停牌地铁应用的(How do I Force suspension of Metro app)

problem how do we force an app to suspend (not shutdown, ...

对于大图像Graphics.DrawImage替代品(Graphics.DrawImage alternatives for large images)

problem i am trying to draw a crosshair ("plu ...

引用类型的行为就像在VB.NET值类型(Reference types behaves like value type in VB.NET)

problem even though "string" is a reference t ...

插入,使用更新和删除从SQL数据库中的数据vb.net?(Insert,update and delete data from Sql database using vb.net)

problem this is my code for inserting data in ...

使用CsvReader从LumenWorks用英寸;"定界符(Using CsvReader From LumenWorks with ";" delimiter)

problem i have two little issues with the csvreader from ...

接收如何从发布/订阅模式创建序列(Rx how to create a sequence from a pub/sub pattern)

problem i'm trying to evaluate using rx to cr ...

包装C#C ++(Wrapping C# C++)

problem i would like to wrap a native library with c++/cl ...

有人企图从这将引起该组件被沙盒网络位置加载程序集(an attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed)

problem .net 4.0 : getting error "an attempt was made to ...

是UnhandledException正常工作在Windows Phone上的所有情况?(Is UnhandledException works properly in all cases on Windows Phone)

problem in my windows phone app i use application.unhandl ...

DataGridView中绘制晶片图(Datagridview to draw wafer map)

problem currently i'm using c# datagridview to draw a waf ...

无缓冲串在内存中写入JSON到流(Writing JSON to a stream without buffering the string in memory)

problem i would like to write json to a stream by buildin ...

杀子进程时,父NT服务被杀害/坠毁(Kill Child Process when Parent NT Service is Killed/Crashed)

problem i have a windows nt service and a third party exe ...

系统:绘制::位图到无符号字符*(System::Drawing::Bitmap to unsigned char *)

problem i have a c# .net library that grabs frames from a ...

保持任务栏上面我的表?(Keep my form above the taskbar)

problem my overall goal is to render a second (or third, ...

异常的玻璃在PageEditor模式映射器Sitecore的(Exception in Glass mapper for Sitecore in PageEditor mode)

problem for the code: strmenutext.append(renderlink(main ...

与接收值之间(Between values with Rx)

problem is there some extension method in rx to do the sc ...