![]() |
#2
xuzongc2014-05-14 20:45
用FIREBUG 分析网页如下
<input name="checkcode1" size="4" maxlength="4" style="BORDER-RIGHT: #81ace4 1px solid; BORDER-TOP: #81ace4 1px solid; BORDER-LEFT: #81ace4 1px solid; WIDTH: 30px; MARGIN-RIGHT: 2px; BORDER-BOTTOM: #81ace4 1px solid; HEIGHT: 16px" id="piatscode1" class="wenbenk"> <input id="piatscode2" class="wenbenk" name="checkcode2" size="4" maxlength="4" style="BORDER-RIGHT: #81ace4 1px solid; BORDER-TOP: #81ace4 1px solid; BORDER-LEFT: #81ace4 1px solid; WIDTH: 30px; MARGIN-RIGHT: 2px; BORDER-BOTTOM: #81ace4 1px solid; HEIGHT: 16px" onkeyup="jump2Field(this,4,'piatscode3');"> <input id="piatscode3" class="wenbenk" name="checkcode3" size="4" maxlength="4" style="BORDER-RIGHT: #81ace4 1px solid; BORDER-TOP: #81ace4 1px solid; BORDER-LEFT: #81ace4 1px solid; WIDTH: 30px; MARGIN-RIGHT: 2px; BORDER-BOTTOM: #81ace4 1px solid; HEIGHT: 16px" onkeyup="jump2Field(this,4,'piatscode4');"> <input id="piatscode4" class="wenbenk" name="checkcode4" size="4" maxlength="4" style="BORDER-RIGHT: #81ace4 1px solid; BORDER-TOP: #81ace4 1px solid; BORDER-LEFT: #81ace4 1px solid; WIDTH: 30px; MARGIN-RIGHT: 2px; BORDER-BOTTOM: #81ace4 1px solid; HEIGHT: 16px" onkeyup="jump2Field(this,4,'piatscode5');"> <input id="piatscode5" class="wenbenk" name="checkcode5" size="4" maxlength="4" style="BORDER-RIGHT: #81ace4 1px solid; BORDER-TOP: #81ace4 1px solid; BORDER-LEFT: #81ace4 1px solid; WIDTH: 30px; MARGIN-RIGHT: 2px; BORDER-BOTTOM: #81ace4 1px solid; HEIGHT: 16px" onkeyup="jump2Field(this,4,'areaNo');" 验证码 <img id="captchaImage" title="点击刷新" src="http://sp. ;="" onclick="javascript:changeCode()" style="CURSOR: pointer"> 提交按钮 <input vspace="5" type="image" hspace="5" height="20" align="middle" name="Submit" src="/images/ivr/search_s.jpg"> |
目标:把EXCEL 中的 药品监管码提交到http://www1.,并提取条形码的药品名称,规格,生产厂家,批号,有效期,批准文号等信息
以下面四个为例
81256200007436720261
81362180000567732475
81320280009831826807
81011570092686473901
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate "http://email.
timeie = DateAdd("s", 10, Now())
Do While ie.Busy And Not ie.readyState = READYSTATE_COMPLETE
DoEvents
If timeie < Now() Then
MsgBox "无法连接网站,请重新执行"
ie.Quit
Exit Sub
End If
Loop
ie.document.getElementById("pwdInput").Value = "xxxx"
ie.document.getElementById("userNameIpt").Value = "xxxxxx"
ie.document.getElementById("btnSubmit").Click
Set ie = Nothing
我叉,这段代码登录163没有问题,奇怪的是登录监管网马上出错
Sub t()
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate "http://www1.
timeie = DateAdd("s", 10, Now())
Do While ie.Busy And Not ie.readyState = READYSTATE_COMPLETE
DoEvents
If timeie < Now() Then
MsgBox "无法连接网站,请重新执行"
ie.Quit
Exit Sub
End If
Loop
ie.document.getElementById("piatscode1").Value = "8125"
ie.document.getElementById("piatscode2").Value = "1025"
' ie.document.getElementById("btnSubmit").Click
Set ie = Nothing
End Sub
两者没什么差别,我只修改下ID,就出现 WITH 对象错误
所以 我百思不得骑姐
以上我是用VBA编的,若用VB编写也是一样,谢谢老师们指点