【发布时间】:2021-06-24 06:12:21
【问题描述】:
我正在尝试使用 MSXML2.XMLHTTP 将数据从多个网站中的第二个传输到 Excel,而无需打开浏览器。意思是主页在数据输入后创建一个查询页面(或查询内容)。
我的代码:
Sub GetData()
Dim HTML As New HTMLDocument, HTMLDoc As New HTMLDocument
Dim elmt As Object
Dim L As Long
Const URL = "http://www.zvg-portal.de/index.php?button=Termine%20suchen"
Const URL1 = "http://www.zvg-portal.de/index.php?button=Suchen"
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", URL, False
.send "land_abk=be&button=suchen"
.Open "GET", URL1, False
.send
HTML.body.innerHTML = .responseText
End With
Set elmt = HTML.querySelectorAll("TR")
For L = 0 To elmt.Length - 1
ActiveSheet.Cells(L + 2, 2) = elmt.Item(L).innerText
Next
End Sub
什么都没有发生。我认为这是因为无法访问查询内容或未构建查询内容。可能是因为错误的BUTTON 代码?我还尝试了 button=submit 和 submit=true 和 suchen=true,但没有成功。如何解决这个问题?谢了!
数据输入主站点的HTML:
<button type=submit>Suchen</button><button type=reset onClick="reset_form()">Zurücksetzen</button><br></h3></nobr><p>
<input type=hidden name=ger_name id=name=ger_name>
<!-- -->
<table border=0><tr><td ><b>Sortiert nach: </></td><td>
<SELECT size=1 name=order_by><option value=2>Termin</option>
<option value=1>Aktualisierung</option>
<option value=3>Aktenzeichen</option>
</td> </tr>
</table>
<!--Land-->
<br>
<table border=0>
<tr><td><font color=red>*</font> <b>Land:</b></td></tr>
<tr><td>
<select size=1 name=land_abk onChange="updateAmtsgericht(this.value);" style="width:643px">
<option value=0>-- Bitte Bundesland auswählen --</option><option value='bw' >Baden-Wuerttemberg</option>
<option value='by' >Bayern</option>
<option value='be' >Berlin</option>
【问题讨论】:
标签: excel vba web-scraping get xmlhttprequest