我想实现网页的填表,但是貌似遇到疑难杂症,我使用的是WebBrowser1.Document.getElementByName("username").Value = Text1
还有:
Dim vDoc, vTagDim i As IntegerSet vDoc = WebBrowser1.DocumentFor i = 0 To vDoc.All.length - 1 '检测所有标签If UCase(vDoc.All(i).tagName) = "input" Then '找到input标签Set vTag = vDoc.All(i)If vTag.Type = "password" Then '看看是不是我们需要的 If vTag.Name = "password" Then vTag.Value = Text1.Text '这里是要搜索的内容End If
End IfNext i
都没有什么作用,请教前辈们,该如何填表?
网页源码如下:<label>
用户名:
</label>
<span class="textbox"> <input class="ipt-t" type="text"
name="username" value="" onfocus="RegisterV2.focus.username()"
onkeyup="RegisterV2.keyup.username()"
onblur="RegisterV2.blur.username()" maxlength="16" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_recommend" style="display:none">
<label> </label>
<div class="textbox">
<div class="h_box" >
<div>推荐您使用以下用户名:</div>
<ol id="msg_recommend"></ol>
</div>
</div>
</div>
<div class="fi cs-clear" id="item_password">
<label>
登录密码:
</label>
<span class="textbox"> <input class="ipt-t" type="password"
name="password" value="" onfocus="RegisterV2.focus.password()"
onkeyup="RegisterV2.keyup.password()"
onblur="RegisterV2.blur.password()" maxlength="20" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_password2">
<label>
确认密码:
</label>
<span class="textbox"> <input class="ipt-t" type="password"
id="password2" value="" onfocus="RegisterV2.focus.password2()"
onkeyup="RegisterV2.keyup.password2()"
onblur="RegisterV2.blur.password2()" maxlength="20" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_securityCode">
<label>
验证码:
</label>
<span class="textbox cs-clear"> <input class="ipt-t"
type="text" name="securityCode1" value=""
onblur="RegisterV2.keyup.securityCode();" maxlength="10" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear fi-yzm" style="margin: 0 0 0 100px;">
<span class="textbox cs-clear"><a
href="javascript:RegisterV2.changeSecurityCode()" title="看不清?换一张?"><img
src="/verify/register.do" id="imgSecurityCode" height="70" />
</a>
</span>
</div>
<div class="fi cs-clear fi-yzm" style="margin: 0 0 5px 100px;">
<span>看不清?<a
href="javascript:RegisterV2.changeSecurityCode()" title="看不清??换一张?">换一张?</a>
</span>
</div>
还有:
Dim vDoc, vTagDim i As IntegerSet vDoc = WebBrowser1.DocumentFor i = 0 To vDoc.All.length - 1 '检测所有标签If UCase(vDoc.All(i).tagName) = "input" Then '找到input标签Set vTag = vDoc.All(i)If vTag.Type = "password" Then '看看是不是我们需要的 If vTag.Name = "password" Then vTag.Value = Text1.Text '这里是要搜索的内容End If
End IfNext i
都没有什么作用,请教前辈们,该如何填表?
网页源码如下:<label>
用户名:
</label>
<span class="textbox"> <input class="ipt-t" type="text"
name="username" value="" onfocus="RegisterV2.focus.username()"
onkeyup="RegisterV2.keyup.username()"
onblur="RegisterV2.blur.username()" maxlength="16" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_recommend" style="display:none">
<label> </label>
<div class="textbox">
<div class="h_box" >
<div>推荐您使用以下用户名:</div>
<ol id="msg_recommend"></ol>
</div>
</div>
</div>
<div class="fi cs-clear" id="item_password">
<label>
登录密码:
</label>
<span class="textbox"> <input class="ipt-t" type="password"
name="password" value="" onfocus="RegisterV2.focus.password()"
onkeyup="RegisterV2.keyup.password()"
onblur="RegisterV2.blur.password()" maxlength="20" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_password2">
<label>
确认密码:
</label>
<span class="textbox"> <input class="ipt-t" type="password"
id="password2" value="" onfocus="RegisterV2.focus.password2()"
onkeyup="RegisterV2.keyup.password2()"
onblur="RegisterV2.blur.password2()" maxlength="20" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear" id="item_securityCode">
<label>
验证码:
</label>
<span class="textbox cs-clear"> <input class="ipt-t"
type="text" name="securityCode1" value=""
onblur="RegisterV2.keyup.securityCode();" maxlength="10" /> </span>
<div class="msg">
<span class=""></span>
</div>
</div>
<div class="fi cs-clear fi-yzm" style="margin: 0 0 0 100px;">
<span class="textbox cs-clear"><a
href="javascript:RegisterV2.changeSecurityCode()" title="看不清?换一张?"><img
src="/verify/register.do" id="imgSecurityCode" height="70" />
</a>
</span>
</div>
<div class="fi cs-clear fi-yzm" style="margin: 0 0 5px 100px;">
<span>看不清?<a
href="javascript:RegisterV2.changeSecurityCode()" title="看不清??换一张?">换一张?</a>
</span>
</div>
'按鈕Click事件
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click '填寫帳號
WebBrowser1.Document.GetElementById("email").SetAttribute("value", "您的帳號") '填寫密碼
WebBrowser1.Document.GetElementById("pass").SetAttribute("value", "您的密碼")
For Each he As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If he.GetAttribute("type") = "submit" And he.GetAttribute("value") = "登入" Then
he.InvokeMember("click") '執行Click動作
End If
Next End Sub
WebBrowser1.Document.GetElementById("pass").SetAttribute("value", "您的密碼")
您好,我想写的就是VB的代码。不是vb.net,请问要怎么做