shahin
Active Member
I've written a macro in vba to get a "name" from a website using POST request. To reach the target page it is necessary to send POST request twice. Firstly, a page opens up like the first image. After clicking on the "search by address" button it leads to another page where two boxes to be filled in. One for street number and the other for street name. After clicking on the search button when the form is done filling then it leads to the target page with the information i'm after. I tested it using msgbox in the script to be sure i'm on the right page. I'm surely on that page and i can see the title of that page which is "HARRIS COUNTY APPRAISAL DISTRICT". However, I can't parse anything from that page. I'm after this name "LARA PEDRO A & MARIA G" from that page.
This is the macro I'm trying with:
There is a table in that page whose html elements I'm attaching below for your consideration:
Search to be made with:
These are the image of two pages following which target page can be reached:
"https://www.dropbox.com/s/e9on9zwqzmcboze/1Untitled.jpg?dl=0"
"https://www.dropbox.com/s/axd66fvozexbefp/Untitled.jpg?dl=0"
This is the macro I'm trying with:
Code:
Sub httpPost()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim ArgStr As String, ArgStr_ano As String
ArgStr = "search=addr"
ArgStr_ano = "TaxYear=2017&stnum=15535&stname=CAMPDEN+HILL+RD"
With http
.Open "POST", "https://public.hcad.org/records/QuickSearch.asp", False
.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"
.setRequestHeader "Referer", "https://public.hcad.org/records/quicksearch.asp"
.send ArgStr
End With
With http
.Open "POST", "https://public.hcad.org/records/QuickRecord.asp", False
.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"
.setRequestHeader "Referer", "https://public.hcad.org/records/quicksearch.asp"
.send ArgStr_ano
html.body.innerHTML = .responseText
End With
MsgBox http.responseText
End Sub
There is a table in that page whose html elements I'm attaching below for your consideration:
Code:
<td class="data" valign="top" nowrap="">
<table width="350">
<tbody><tr>
<td valign="top" nowrap="">Owner Name &<br>Mailing Address:</td>
<th align="left" valign="top" nowrap="">
<!-- ---------- OWNER NAME ---------- -->
LARA PEDRO A & MARIA G<br>
<!-- ---------- MAILING ADDRESS ---------- -->
<!-- ---------- MAILING ADDRESS (MAIL TO) ---------- -->
<!-- ---------- MAILING ADDRESS (ADDR1 AND ADDR2) ---------- -->
15531 CAMPDEN HILL RD<br>
<!--
------------------------------------------------
'RA 09/11/2012:
Changed order of Owner / Address to :
Owner Name(s)
MailTo
Addr_1
Addr_2
City
State
Zip
Country
------------------------------------------------
15531 CAMPDEN HILL RD
------------------------------------------------
-->
<!-- ---------- MAILING ADDRESS (CITY-STATE-ZIP OR COUNTRY)---------- -->
HOUSTON TX 77053-3302<br>
<!--<br />-->
</th>
</tr>
</tbody></table>
</td>
Search to be made with:
Code:
Street No: 15535
Street Name: CAMPDEN HILL RD
These are the image of two pages following which target page can be reached:
"https://www.dropbox.com/s/e9on9zwqzmcboze/1Untitled.jpg?dl=0"
"https://www.dropbox.com/s/axd66fvozexbefp/Untitled.jpg?dl=0"