面向初学者的C#;)如何从以下Web表单编码GetElementsByTagName [英] C# for beginners ;) How to code GetElementsByTagName from the following webform

查看:75
本文介绍了面向初学者的C#;)如何从以下Web表单编码GetElementsByTagName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我目前正在为我的客户开发软件,这些客户可以使用我的会员权利免费订购SIMCARD,并且我正在尝试开发可以帮助我解决此问题的应用程序.
我对c#编程的了解很少,但是我尝试做我的第一个项目,并且学习缓慢,所以这是我对所有专业人士的问题.

我需要自动填写以下网络表单:


https://leadintelligence.co.uk/register/314/70/234/?sourceData=TopCashBack&sourceAffiliateId=null&



1.用提供的
填充Web表单

Hello,

I am currently developing a Software for my clients who can free of charge order a SIMCARD using my affiliate rights, and I am trying to develop a application that can help me with that.
I have very little knowledge about c# programming, but I attempted to do my first project, and I am learning it slowly, so here is my question to all those PROFESSIONALS out there.

I need to Automatically Fill in the following webform:


https://leadintelligence.co.uk/register/314/70/234/?sourceData=TopCashBack&sourceAffiliateId=null&



1. Fill the Webform with the provided

"First Name,          using TextBox1"  SAMPLE FIRSTNAME:(SAMPLE1)
"Last Name,           using TextBox2"  SAMPLE LASTNAME: (SAMPLE2
"Email,               using TextBox3"  SAMPLE EMAIL:    (abcde@acdb.com)
"Address Line 1,      using TextBox4"  SAMPLE ADDRESS:  (abcdesf)
"Postcode,            using TextBox5"  SAMPLE POSTCODE: (OX1 4AS)


-------------------------------------------------- ---------------
2.单击查找地址按钮"
然后会打开一个小多行窗口",我必须选择地址
已找到正确的门牌号.我想
以后会自动使用复选框选择第二行.
-------------------------------------------------- ---------------
3.选择地址/地址行,然后按选择"按钮.

5.按向我发送我的免费Sim".

如果有任何帮助,或者对那些发现这很容易的人,我将不胜感激,并且可以帮助我自动填写此表单,也只需单击一下即可提交此表单.

.....................我认为此处无法上载应用程序的源代码. ..........

也许您可以只看一下我提供的网站,并从中告诉我GetElementsByTagName的方法.


-----------------------------------------------------------------
2. Click on "Find Address Button"
Then a small Multiline Window opens and I must select the address
that has been found and the correct House Number. I would like to
Automatically select the 2nd line with a checkbox in the future.
-----------------------------------------------------------------
3. Choose address/acddress-Line and Press "Select" Button.

5. Press "Send me My Free Sim".

I would appreciate any help or for those out there that find this a piece of cake, and could help me Autofill in this form and with one click submit this form as well.

..............................I SEEM TO NOT BE ABLE TO UPLOAD THE SOURCE CODE OF THE APPLICATION ON HERE..............

Maybe you could just look at the website i provided and tell me the ways of GetElementsByTagName from it.

推荐答案

我还没有访问过该网站,或者我也不会或者大多数这里的人.但是,您无需填写网络表单即可提交数据.通常,单击提交"按钮后,会将HTTP POST发送到服务器,其中包含来自编码到其中的表单字段中的数据.

http://msdn.microsoft.com/en-us/library/debx8sh9.aspx [ ^ ]
I have not visited the site, nor will I, or most people here. However, you don''t need to fill-in a webform to submit data. In general when a submit button is clicked a HTTP POST is send to the server with the data from the form fields encoded into it.

http://msdn.microsoft.com/en-us/library/debx8sh9.aspx[^]


我认为Watin Core库将对您有所帮助...
I think Watin Core library will be helpful for you......


第一个选项:
我找到了一种填写表格的方法,我在那里询问了所有专业人员.同时,我自己进行了研究,找到了GetElementsById.

wb.Document.GetElementById("q_772_2_answer").SetAttribute("value",textBox5.Text);

wb.Document.GetElementById("q_772_3_answer").SetAttribute("value",textBox4.Text);

wb.Document.GetElementById("q_773_answer").SetAttribute("value",textBox10.Text);

wb.Document.GetElementById("q_774_userAddress").SetAttribute("value",textBox9.Text);

wb.Document.GetElementById("q_774_userPostcode").SetAttribute("value",textBox7.Text);

wb.Document.GetElementById("q_774_lookup").InvokeMember("click");


-------------------------------------------------- -------------------------------
第二个选择:

HtmlElementCollection标签= wb.Document.Body.GetElementsByTagName("input");
foreach(标签中的HtmlElement t)
如果(t.GetAttribute("name").Equals("first_name"))
{
t.SetAttribute("value",名字的值");
}

foreach(标签中的HtmlElement t)
如果(t.GetAttribute("name").Equals("last_name"))
{
t.SetAttribute("value",姓氏的值");
}
foreach(标签中的HtmlElement t)
如果(t.GetAttribute("name").Equals("email_address"))
{
t.SetAttribute("value",电子邮件地址的值");
}
foreach(标签中的HtmlElement t)
如果(t.GetAttribute("name").Equals("userAddress"))
{
t.SetAttribute("value",地址的值");
}
foreach(标签中的HtmlElement t)
如果(t.GetAttribute("name").Equals("userPostcode"))
{
t.SetAttribute("value",姓氏的值");
-------------------------------------------------- -------------------------------
1st option:
I have found some way to fill the forms i asked all of you professionals out there. In the meantime, i researched it myself and found GetElementsById.

wb.Document.GetElementById("q_772_2_answer").SetAttribute("value", textBox5.Text);

wb.Document.GetElementById("q_772_3_answer").SetAttribute("value", textBox4.Text);

wb.Document.GetElementById("q_773_answer").SetAttribute("value", textBox10.Text);

wb.Document.GetElementById("q_774_userAddress").SetAttribute("value", textBox9.Text);

wb.Document.GetElementById("q_774_userPostcode").SetAttribute("value", textBox7.Text);

wb.Document.GetElementById("q_774_lookup").InvokeMember("click");


---------------------------------------------------------------------------------
2nd option:

HtmlElementCollection tags = wb.Document.Body.GetElementsByTagName("input");
foreach (HtmlElement t in tags)
if (t.GetAttribute("name").Equals("first_name"))
{
t.SetAttribute("value", "value of First Name");
}

foreach (HtmlElement t in tags)
if (t.GetAttribute("name").Equals("last_name"))
{
t.SetAttribute("value", "value of last name");
}
foreach (HtmlElement t in tags)
if (t.GetAttribute("name").Equals("email_address"))
{
t.SetAttribute("value", "value of email address");
}
foreach (HtmlElement t in tags)
if (t.GetAttribute("name").Equals("userAddress"))
{
t.SetAttribute("value", "value of Address");
}
foreach (HtmlElement t in tags)
if (t.GetAttribute("name").Equals("userPostcode"))
{
t.SetAttribute("value", "value of last name");
---------------------------------------------------------------------------------


这篇关于面向初学者的C#;)如何从以下Web表单编码GetElementsByTagName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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