Hi @Malik Asad Mahmood ,
You need to know how to use HTML Agility Pack to get data from HTML table.
Here's an example you can refer to.
Dim webClient As WebClient = New WebClient()
Dim page As String = webClient.DownloadString("https://www.psx.com.pk/market-summary/")
Dim doc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
doc.LoadHtml(page)
Dim lstNode As List(Of HtmlNode) = New List(Of HtmlNode)
Dim lstName As List(Of String) = New List(Of String)
Dim lstTable As List(Of DataTable) = New List(Of DataTable)
For Each thed As HtmlNode In doc.DocumentNode.SelectNodes("//thead")
lstNode.Add(thed.ParentNode)
Dim text = thed.SelectSingleNode("tr").SelectSingleNode("th").SelectSingleNode("h4").InnerText
Console.WriteLine(text)
lstName.Add(text)
Next
For i As Integer = 0 To lstNode.Count - 1
Dim dt As DataTable = New DataTable
dt.TableName = lstName(i)
For Each trNode As HtmlNode In lstNode(i).SelectNodes("tr")
If trNode.Attributes("class") Is Nothing Then
For Each colNode As HtmlNode In trNode.SelectNodes("td")
dt.Columns.Add(colNode.InnerText)
Next
Else
Dim j As Integer = 0
Dim row As DataRow = dt.NewRow()
For Each rowNode As HtmlNode In trNode.SelectNodes("td")
row(j) = rowNode.InnerText
j += 1
Next
dt.Rows.Add(row)
End If
Next
lstTable.Add(dt)
Next
Hope it could be helpful.
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.