2021-03-30

How to transfer data from multiple websites to Excel with MSXML2.XMLHTTP

I am trying to transfer data from multiple Websites to Excel. It is meant that the homepage creates a query page after data input.

In main-site:

http://www.zvg-portal.de/index.php?button=Termine%20suchen

with MSXML2.XMLHTTP I choose for example "Berlin" in dropdown LAND, it changes to a query-site:

http://www.zvg-portal.de/index.php?button=Suchen

and there I try to access this content:

(HTML part:)

<td valign="top" align="left">Objekt/Lage</td>
<td colspan="2" valign="center" align="left">
<b>
Eigentumswohnung (3 bis 4 Zimmer)
<!--Lage--->
:
</b> 
Schützenstraße  41, 10117 Berlin, Mitte
</td>

with my code:

Sub GetDataInformation()
  Dim xml    As Object
  Dim html   As Object
  Dim elements As Object
Set xml = CreateObject("MSXML2.XMLHTTP")
Set html = CreateObject("htmlFile")
   With xml
      .Open "POST", "http://www.zvg-portal.de/index.php?button=Termine%20suchen", False
      .setRequestHeader "Content-type", "application/x-www-form-urlencoded"
      .send "updateAmtsgericht=be"  ' OR .send "land_abk=be"
      .Open "GET", "http://www.zvg-portal.de/index.php?button=Suchen", False
      .setRequestHeader "Content-type", "text/xml"
      .send
   End With
html.body.innerHTML = xml.responseText
Set elements = html.querySelectorAll("td")   ' OR ("b")
   For y = 0 To elements.Length - 1
      ActiveSheet.Cells(y + 2, 2) = elements.Item(y).innerText
   Next
End Sub

but I just get an ERROR: queryselectorall can't be used for this element: html.querySelectorAll("form_sucheZvg")

how can this problem be solved?



from Recent Questions - Stack Overflow https://ift.tt/3m4cRRs
https://ift.tt/eA8V8J

No comments:

Post a Comment