这个网站使用XMLHTTP需要什么参数?
What parameters does this website need to use XMLHTTP?
我无法弄清楚需要将哪些参数从父页面(VBA)发送到子页面才能访问数据。我尝试使用引荐来源网址(主页 URL)和 HTML 文本中的各种详细信息作为 POST,但 Excel 在每次尝试调用该页面时都挂起使用 XMLHTTP!
实际上,在主站点上,只需select下拉列表中的一个值,然后单击搜索按钮,而无需填写其他字段,但子页面仍然没有响应POST 的相关 ID 值。
<select name="Vort" size="1">
<option size="30" value="%"></option>
<option value="60467"</option>
<option value="60470"</option>
<option value="60468"</option>
...
有什么想法吗?我的 VBA 代码(Excel 挂起,无论使用哪个 POST 参数(S)):
Public Sub GETDATA()
Dim html As New HTMLDocument, Htmldoc As New HTMLDocument, x As Long
With CreateObject("MSXML2.ServerXMLHTTP.6.0")
.Open "Post", URL, False
.send '?
html.body.innerHTML = .responseText
End With
For x = 0 To 10
Htmldoc = html.querySelectorAll("th").Item(x)
ActiveSheet.Cells(x + 2, 2) = Htmldoc.innerText
Next
End Sub
要获得所需的响应,您需要在 post 请求中发送适当的参数以及内容类型 headers。
以下 post 请求中使用的参数基于此 selection。
Public Sub GetContent()
Const link = "https://www.thueringen.de/olgneu/zvg/dosearch2_neu.asp"
Dim oHtml As HTMLDocument, payload$
Set oHtml = New HTMLDocument
payload = "REASON=FULL_SEARCH&START_AT=1&Objekte_Ort=&VersteigerungsOrt=60467&Aktenzeichen=&ObjektWert_von=&ObjektWert_bis=&Termin_Ab=26.4.2021&Termin_Bis=&MAX_HIT=10"
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", link, False
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send (payload)
oHtml.body.innerHTML = .responseText
End With
MsgBox oHtml.querySelector("tr.klein a[href]").href
End Sub
我无法弄清楚需要将哪些参数从父页面(VBA)发送到子页面才能访问数据。我尝试使用引荐来源网址(主页 URL)和 HTML 文本中的各种详细信息作为 POST,但 Excel 在每次尝试调用该页面时都挂起使用 XMLHTTP!
实际上,在主站点上,只需select下拉列表中的一个值,然后单击搜索按钮,而无需填写其他字段,但子页面仍然没有响应POST 的相关 ID 值。
<select name="Vort" size="1">
<option size="30" value="%"></option>
<option value="60467"</option>
<option value="60470"</option>
<option value="60468"</option>
...
有什么想法吗?我的 VBA 代码(Excel 挂起,无论使用哪个 POST 参数(S)):
Public Sub GETDATA()
Dim html As New HTMLDocument, Htmldoc As New HTMLDocument, x As Long
With CreateObject("MSXML2.ServerXMLHTTP.6.0")
.Open "Post", URL, False
.send '?
html.body.innerHTML = .responseText
End With
For x = 0 To 10
Htmldoc = html.querySelectorAll("th").Item(x)
ActiveSheet.Cells(x + 2, 2) = Htmldoc.innerText
Next
End Sub
要获得所需的响应,您需要在 post 请求中发送适当的参数以及内容类型 headers。
以下 post 请求中使用的参数基于此 selection。
Public Sub GetContent()
Const link = "https://www.thueringen.de/olgneu/zvg/dosearch2_neu.asp"
Dim oHtml As HTMLDocument, payload$
Set oHtml = New HTMLDocument
payload = "REASON=FULL_SEARCH&START_AT=1&Objekte_Ort=&VersteigerungsOrt=60467&Aktenzeichen=&ObjektWert_von=&ObjektWert_bis=&Termin_Ab=26.4.2021&Termin_Bis=&MAX_HIT=10"
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", link, False
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send (payload)
oHtml.body.innerHTML = .responseText
End With
MsgBox oHtml.querySelector("tr.klein a[href]").href
End Sub