Macro / VBA to fetch values from www.Eppraisal.com

对着背影说爱祢 提交于 2019-12-14 03:58:26

问题


I need to fetch some values from www.Eppraisa.com using Excel Macro.

But I don't know what should be the value of PropID. That's why the macro works for URL1 but not for URL2 because I think URL2 has a wrong propID

Const URL1 As String = "http://www.eppraisal.com/home-values/property_lookup_eppraisal?a=1122%20E%20Loyola%20Dr&z=85282&propid=42382460"

Const URL2 As String = "http://www.eppraisal.com/home-values/property_lookup_eppraisal?a=19732%20E%20Reins%20Rd&z=85142&propid=31402642"

Sub xmlHttp() Dim xmlHttp As Object Set xmlHttp = CreateObject("MSXML2.XMLHTTP")

' This works
xmlHttp.Open "GET", URL1, False

' But doesn't work for below url :(
'xmlHttp.Open "GET", URL2, False

xmlHttp.setRequestHeader "Content-Type", "text/xml"


xmlHttp.send

Dim ieDom As New HTMLDocument
Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.responseText
Debug.Print html.body.innerHTML
ieDom.body.innerHTML = xmlHttp.responseText

For Each ieInp In ieDom.getElementsByTagName("p")
    If ieInp.className = "ColorAccent6 FontBold FontSizeM Margin0 Padding0" Then
        strEppraisalValue = ieInp.innerText
    ElseIf ieInp.className = "FontSizeA Margin0 DisplayNone HighLow" Then
        strEppraisalHighLow = ieInp.innerText
    End If
Next End Sub

Can anybody please help? It would be a great help for me

Thanks.


回答1:


With Mozilla Firefox & Firebug you can identify the request and response.

Below step applies to any search you make.

1 Copy the below URL to Firefox Browser.

http://www.eppraisal.com/home-values/property/1122-e-loyola-dr-tempe-az-85282-42382460/

2 Open Up FireBug and look for below request. Goto Net Tab > XHR as in below image.

3 Expand the node and goto Params tab. It shows all the input parameters which needs to go with the GET request.

.

4 Finally we can see the response from server in the Response Tab.



来源:https://stackoverflow.com/questions/17873592/macro-vba-to-fetch-values-from-www-eppraisal-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!