Dim str As String = ""
For Each h As HtmlElement In Web.Document.GetElementsByTagName(txtTagName.Text)
If Not Object.ReferenceEquals(h.GetAttribute(txtGetAtt.Text), Nothing) AndAlso h.GetAttribute(txtGetAtt.Text).Equals(txtGetAttEquals.Text) Then
If str.ToString.Split(",").Length = 4 AndAlso IsNumeric(h.InnerText) = False Then
Exit For
Else
str &= If(str = "", "", ",") & h.InnerText.Trim
End If
If str.ToString.Split(",").Length = 5 Then
strText.Text &= If(String.IsNullOrEmpty(strText.Text), "", vbNewLine) & str.ToString
str = ""
End If
ElseIf Not Object.ReferenceEquals(h.GetAttribute(txtGetErrorAtt.Text), Nothing) AndAlso (h.GetAttribute(txtGetErrorAtt.Text).Equals(txtGetErrorAttEquals.Text) And Not String.IsNullOrEmpty(h.InnerText)) Then
strText.Text = h.InnerText.Trim
Exit For
End If
Next
Private Sub SurroundingSub()
Dim startPeriod As String = "2019-01-05"
Dim endPeriod As String = "2019-01-05"
Dim client = New RestClient("https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/?start_period=" & startPeriod & "&end_period=" & endPeriod)
Dim request = New RestRequest(Method.[GET])
request.AddHeader("Accept", "application/json")
request.AddHeader("x-ibm-client-id", "REPLACE_THIS_KEY")
Dim response As IRestResponse = client.Execute(request)
If response.StatusCode.Equals(HttpStatusCode.OK) Then
Console.WriteLine(response.Content)
End If
End Sub