'Click on hyperlink when scraping data from a table
I am trying to scape data from a web table.
I login to a website, which gives me access to a web table.
That table contains a hyperlink column (Id) like the example you can see below. I want to click on id "3547" when the PO = "WO-JL31" for example.
ID \\ \ Date \\ \ \\ PO\\ \\ Amount
3547\\02/2022\WO-JL31\ $3254
I am able to read and debug.print
the whole html file of the table.
How do I click on 3524?
Dim HTMLTables As MSHTML.IHTMLElementCollection
Dim HTMLTable As MSHTML.IHTMLElement
Dim HTMLDetails As MSHTML.IHTMLElementCollection
Dim HTMLDetail As MSHTML.IHTMLElement
Dim HTMLTableSection As MSHTML.IHTMLElement
Dim HTMLTableRow As MSHTML.IHTMLElement
Dim HTMLTableCell As MSHTML.IHTMLElement
Dim RowText As String
Set HTMLTable = HTMLDoc.getElementsByTagName("table")(2)
Set HTMLDetails = HTMLDoc.getElementsByTagName("td")
For Each HTMLTableSection In HTMLTable.Children
Debug.Print , HTMLTableSection.tagName
For Each HTMLTableRow In HTMLTableSection.Children
RowText = ""
For Each HTMLTableCell In HTMLTableRow.Children
RowText = RowText & vbTab & HTMLTableCell.innerText
' From here I am able to print only the row of the table
' were the PO = “WO-JL31” as you can see the code below.
' (I am not sure if this is the best way to do it as it
' takes too much time to print.)
If InStr(RowText, "KA-PL32") > 0 Then
Debug.Print , , RowText
Exit For
End If
Next HTMLTableCell
Next HTMLTableRow
Next HTMLTableSection
This is the result: 3547 WO-JL31
How do I click on the hyperlink 3547 where the PO= WO-JL31?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|