Log in

View Full Version : Get the max value from a web page



sal21
08-17-2025, 07:52 AM
i need to get the max value from the button...

for year 2000 the max value is 3
for year 1997 the max value is 2
...
ecc...


see imge

actually i use this api:

With WHTTP
.setTimeouts 50000, 50000, 15000, 15000
.Open "GET", "https://www.xamig.com/superenalotto/1997/estrazioni.php", Rnd, False
.send
Sleep (500)
'Do Until html.ReadyState = 4
'Loop
html.body.innerHTML = .responseText
End With

Artik
09-30-2025, 06:03 PM
Try it

Sub GetPageCount()
Dim http As Object
Dim html As Object
Dim pageCount As Integer
Dim i As Integer
Dim url As String
Dim matches As Object
Dim regex As Object
url = "https://www.xamig.com/superenalotto/2024/estrazioni.php"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url, False
http.Send
Set html = CreateObject("htmlfile")
html.body.innerHTML = http.responseText
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True
.IgnoreCase = True
.Pattern = "estrazioni\.php\?page=(\d+)"
End With
Set matches = regex.Execute(http.responseText)
pageCount = 1
For i = 0 To matches.Count - 1
If CInt(matches(i).SubMatches(0)) > pageCount Then
pageCount = CInt(matches(i).SubMatches(0))
End If
Next i
MsgBox "Number of pages available: " & pageCount
End Sub
Artik