Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

possible to use xml2 or Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1"), instead code in message

2009luca

Programmer
Jul 27, 2013
226
IT
Sub AMBI_lottobook()

Dim IE As Object
Dim HTML As Object
Dim MYTABLE As Object
Dim AMBO As String, T As Integer, NUMCELLE As Integer
Dim R As Long, L As Integer, RUOTA As String
Dim C As Long, S As Integer, NUMTAB As Integer
Dim FREQ As String

Set IE = CreateObject("InternetExplorer.Application")
Sleep (500)

IE.Visible = False
IE.Silent = True

Call DeleteUrlCacheEntry("https://www.lottobook.it/lotto/ambi-frequenti-lotto/")

IE.navigate "https://www.lottobook.it/lotto/ambi-frequenti-lotto/"
Sleep (500)

Do While IE.Busy Or IE.readyState <> 4
DoEvents
Loop

Set HTML = IE.document

With HTML
R = 0
For L = 0 To 20 Step 2
RUOTA = .All.tags("table")(0).Rows(L).Cells(0).innerText
Debug.Print RUOTA

For C = 0 To 5 - 1
AMBO = .All.tags("table")(0).Rows(L).Cells(C + 2).innerText
Debug.Print AMBO
FREQ = .All.tags("table")(0).Rows(L + 1).Cells(C + 1).innerText
Debug.Print FREQ
Next C
R = R + 1
Next L
End With

' Clean up
Set HTML = Nothing
IE.Quit
Set IE = Nothing

End Sub
 
mxxml2.XMLHTTP and WinHTTP.WinHTTPrequest.5.1 are for most of your purposes pretty much the same thing, and you can use either interchangeably, i.e wherever you might use

CreateObject("MSXML2.XMLHTTP")

you can instead use

CreateObject("WinHTTP.WinHTTPrequest.5.1")

with no other changes needed. We've shown you various examples of using XMLHTTP to retrieve the HTML from URL and put it into an HTM:L document, so it unclear to me how/why you need to ask us this question.
 
my test code, dont work

i'm not sure when invoche the class name, which is?

Sub TpData()

Const URL = "https://www.lottobook.it/lotto/ambi-frequenti-lotto/"
Dim http As New XMLHTTP60, html As New HTMLDocument, post As Object, i

With http
.Open "GET", URL, False
.send
html.body.innerHTML = .responseText
End With

For Each post In html.getElementsByClassName("table-responsive")(0).getElementsByTagName("td")
With post.getElementsByTagName("a")
If .Length Then i = i + 1: Cells(i, 1) = .item(0).innerText
End With
Next post

End Sub
 
Use below URL instead.

Code:
https://www.lottobook.it/mycontent/lotto/ambiFrequenti.php
 
>my test code, dont work

If you mean the code in the first post here, then it works fine here. But I'm on Windows 10 and, whilst IE has been 'removed' from Windows, the com library, Internet Controls, which is "internet.explorer", still works fine. I am led to believe that some installations it no longer works. In which case, you may have a bigger problem since neither XMLHTTP nor WinHTTPrequest.5.1 play nice with dynamic code driven pages, which I'v e just noticed you target URL is.

You may, as previously advised, want to look at WebView2 or Selenium

(that being said, you have previously indicated that internet.application does work for you, so the problem may be elsewhere. Do you have Sleep and DeleteUrlCacheEntry appropriately defined?)
 

Part and Inventory Search

Sponsor

Back
Top