hr2*_*d33 3 vba msxml xmlhttprequest excel-vba excel-2010
我经常需要在NV的状态下搜索无人认领的属性,并将结果放在Excel电子表格中.我正在尝试自动化该过程,但我仅限于使用Excel 2010和VBA.下面是我尝试使用xmlhttp提交表单的网站的URL.
网址:https://nevadatreasurer.gov/UPSearch/
我创建了一个类来自动在其他网站上提交表单,但无论我在postdata中输入什么,表单都从未提交.以下是我的提交和提交表单的方法.
打电话到课堂:
cXML.openWebsite "Post", "https://nevadatreasurer.gov/UPSearch/Index.aspx", _
"ctl04$txtOwner=" & strSearchName
Run Code Online (Sandbox Code Playgroud)
分类方法:
Public Sub openWebsite(strOpenMethod As String, strURL As String, _
Optional strPostData As String)
pXmlHttp.Open strOpenMethod, strURL
If strPostData <> "" Then
strPostData = convertSpaceToPlus(strPostData)
pXmlHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
pXmlHttp.send (strPostData)
Else
pXmlHttp.send
End If
'Create DOM html documnet
pHtmlObj.body.innerHTML = pXmlHttp.responseText
End Sub
Run Code Online (Sandbox Code Playgroud)
每次responseText是没有更新的主网站,好像我没有提交postdata.我是IE自动化的新手,但是有人可以提供一个不工作的原因和一个有效的代码示例吗?
谢谢!
更新:2013年7月26日上午8:30太平洋标准时间
我没有对我的方法进行任何更改,我可以通过其他网站提交表单.OR无人认领的财产形式.它工作得很完美!
网址:https://oregonup.us/upweb/up/UP_search.asp
但是,当我尝试CA无人认领的房产网站时,我遇到了同样的问题.无论我做什么,responseText始终是原始搜索页面,没有更新.
网址:https://scoweb.sco.ca.gov/UCP/Default.aspx
它仍然不适用于原始帖子中的NV状态.我正在使用适当的帖子数据,为每个网站编码的URL,并没有看到任何区别.任何帮助,将不胜感激.
试试下面的代码
Public Sub openWebsite(strOpenMethod As String, strURL As String, Optional strPostData As String)
Dim pXmlHttp As Object
Set pXmlHttp = CreateObject("MSXML2.XMLHTTP")
pXmlHttp.Open strOpenMethod, strURL, False
pXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
pXmlHttp.send (strPostData)
Dim pHtmlObj As Object
Set pHtmlObj = CreateObject("htmlfile")
pHtmlObj.body.innerHTML = pXmlHttp.ResponseText
MsgBox pXmlHttp.ResponseText
End Sub
Sub test()
Dim btnSearch As String, strSearchType As String, strSearchName As String, PostData As String
btnSearch = "Search"
strSearchType = "Owner"
strSearchName = "Santosh"
PostData = "ctl04%24txtOwner=" & strSearchName & "&ctl04%24btnSearch=" & btnSearch & "&ctl04%24rblSearchType=" & strSearchType
openWebsite "POST", "https://nevadatreasurer.gov/UPSearch/Index.aspx", PostData
End Sub
Run Code Online (Sandbox Code Playgroud)
使用Firebug发布数据视图

URL编码

ResponeText

| 归档时间: |
|
| 查看次数: |
10642 次 |
| 最近记录: |