I want to programmatically copy the contents of the webpage. At present i start a Process.Start("firefox.exe", "https://www.thelott.com/powerball/results")
You can get the JSON response and parse it
Test with Newtonsoft.Json :
I get
Value: ProductId=Powerball
Value: DrawNumber=1397
Value: DrawDate=23/02/2023 00:00:00
etc...
Test code :
Try
Dim webRequest As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create("https://data.api.thelott.com/sales/vmax/web/data/lotto/latestresults"), Net.HttpWebRequest)
If webRequest IsNot Nothing Then
webRequest.Method = "POST"
webRequest.Headers.Add("Accept-Encoding", "gzip, deflate, br")
webRequest.Headers.Add("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
Dim encoder As ASCIIEncoding = New ASCIIEncoding()
Dim data = encoder.GetBytes("{""CompanyId"":""NTLotteries"",""MaxDrawCountPerProduct"":1,""OptionalProductFilter"":[""Powerball""]}")
webRequest.ContentType = "application/json"
webRequest.ContentLength = data.Length
webRequest.Expect = "application/json"
webRequest.AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate
webRequest.GetRequestStream().Write(data, 0, data.Length)
Using s As Stream = webRequest.GetResponse().GetResponseStream()
Using sr As StreamReader = New StreamReader(s)
Dim httpWebResponse = sr.ReadToEnd()
Console.WriteLine(String.Format("Response: {0} {1}", Environment.NewLine, httpWebResponse))
Dim respJson = JsonConvert.DeserializeObject(httpWebResponse)
Dim firstResult = DirectCast(DirectCast(DirectCast(respJson, Newtonsoft.Json.Linq.JContainer).First,
Newtonsoft.Json.Linq.JContainer).First, Newtonsoft.Json.Linq.JContainer).First
For Each result In firstResult
Dim sName = DirectCast(result, Newtonsoft.Json.Linq.JProperty).Name
Dim sValue = DirectCast(result, Newtonsoft.Json.Linq.JProperty).Value
Console.WriteLine(String.Format("Value: {0}={1}", sName, sValue))
Next
End Using
End Using
End If
Catch ex As Exception
Console.WriteLine("Error : {0} - {1}", ex.Message, String.Format("0x{0:X}", ex.HResult))
End Try