Moderatori: Anthony47, Flash30005
Sub importarisultati()
'>>>
Dim html_Content As Object, COLL As Object
'<<<
http1.send
Texthh = http1.responseText
Texthh = Replace(Texthh, Chr(34), "")
'>>>
Set html_Content = CreateObject("htmlfile")
html_Content.body.innerHTML = http1.responseText
'<<<
con1 = "js-partial"
posin = posiz6
'>>>
Set COLL = html_Content.getElementById("match-date")
mysplit = Split(COLL.getAttribute("data-dt"), ",", , vbTextCompare)
Cells(x, 13) = DateSerial(mysplit(2), mysplit(1), mysplit(0)) + TimeSerial(mysplit(3), mysplit(4), 0)
Set COLL = html_Content.getElementById("js-score")
Cells(x, 14) = "'" & COLL.innerText
Set COLL = html_Content.getElementById("js-partial")
Cells(x, 15) = COLL.innerText
'<<<
50 Next t
Non voglio toccare la macro perche' faccio fatica a decodificarla (perche' contorta); mi limito quindi a suggerire di eliminare le istruzioni che compilano quelle colonne, che sono queste:grazie Anthony
funziona perfettamente
vorrei chiederti un altra cortesia
se si potrebbe snellire la macro eliminando la parte di codice che importa i dati da colonna f alla colonna k visto che con il tuo intervento vengono importati di nuovo.
Cells(x, 6) = gsq1
Cells(x, 7) = gsq2
Cells(x, 8) = rsqh1
If Cells(x, 8) = "" Then Cells(x, 8) = gsq1
Cells(x, 9) = rsqa1
If Cells(x, 9) = "" Then Cells(x, 9) = gsq2
Cells(x, 10) = rsqh2
If Cells(x, 10) = "" Then Cells(x, 10) = 0
Cells(x, 11) = rsqa2
If Cells(x, 11) = "" Then Cells(x, 11) = 0
#If VBA7 Then '!!! ON TOP OF THE VBA MODULE !!!!
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Sub GetByAnth()
Dim IE As Object, IE2 As Object
Dim AColl As Object, BColl As Object, myTbl As Object, myBItm As Object
Dim tCol As Object
'
Set IE = CreateObject("InternetExplorer.Application")
Set IE2 = CreateObject("InternetExplorer.Application")
Range("A:G").Clear
myurl = "https://www.betexplorer.com/soccer/brazil/serie-a/results/"
IE.Visible = True
resp = GimmePage(myurl, IE)
If resp <> 0 Then Stop
Set AColl = Nothing
Set myTbl = IE.document.getElementById("js-leagueresults-all")
If myTbl Is Nothing Then GoTo TERM
On Error Resume Next
Set AColl = myTbl.getElementsByTagName("tr")
Debug.Print "AA: " & AColl.Length
'
For i = 0 To AColl.Length - 1
j = 0
For Each tCol In AColl(i).Cells
j = j + 1
Cells(i + 2, j).Value = "'" & tCol.innerText
If InStr(1, tCol.outerHTML, "href=", vbTextCompare) > 0 And j = 1 Then
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i + 2, j), Address:=tCol.getElementsByTagName("a")(0).href, _
TextToDisplay:=Cells(i + 2, j).Value
Debug.Print "CC", Timer
resp = GimmePage(tCol.getElementsByTagName("a")(0).href, IE2)
If resp = 0 Then
'' IE2.Visible = True
Set myBItm = Nothing
Set myBItm = IE2.document.getElementById("js-partial")
If myBItm Is Nothing Then
Cells(i + 2, "G").Value = "?? Missing"
Else
Cells(i + 2, "G").Value = myBItm.innerText
End If
End If
Debug.Print "DD", Timer
End If
Next tCol
DoEvents
Debug.Print "EE", Timer
Next i
MsgBox ("Importate " & i - 1 & " righe")
'
TERM:
On Error Resume Next
IE.Quit
IE2.Quit
Set IE = Nothing
Set IE2 = Nothing
End Sub
Function GimmePage(ByVal LUrl As String, LIE As Object) As Long
Dim mTim As Single
With LIE
.navigate LUrl
mytim = Timer
Sleep 100
Do
Sleep 30
If .busy = False And .readyState = 4 Then Exit Do
If Timer > (mytim + 10) Then
If .readyState <> 4 Then GimmePage = 10
If .busy Then WaitPage = GimmePage + 1
Exit Do
End If
DoEvents
Loop
End With
End Function
grazie
Anthony47
funziona perfettamente
un ultima cosa
avrei la necessita di prelevare questo link
https://www.betexplorer.com/soccer/braz ... a/results/
direttamente da una cella per esempio m1
perchè devo automatizzare diversi link
cioè sostituire questo
myURL = "https://www.betexplorer.com/soccer/brazil/serie-a/results/"
myURL = Range("M1").Value
Set IE2 = CreateObject("InternetExplorer.Application")
Range("AA:AG").Clear 'MMM
For i = 0 To AColl.Length - 1
j = 26 'MMM
For Each tCol In AColl(i).Cells
j = j + 1
Cells(i + 2, j).Value = "'" & tCol.innerText
If InStr(1, tCol.outerHTML, "href=", vbTextCompare) > 0 And j = 27 Then 'MMM
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i + 2, j), Address:=tCol.getElementsByTagName("a")(0).href, _
TextToDisplay:=Cells(i + 2, j).Value
If myBItm Is Nothing Then
Cells(i + 2, "AG").Value = "?? Missing" 'MMM
Else
Cells(i + 2, "AG").Value = myBItm.innerText 'MMM
End If
Torna a Applicazioni Office Windows
Eliminare righe diverse dalla prima data del mese Autore: dipdip |
Forum: Applicazioni Office Windows Risposte: 4 |
adattare il contenuto alla pagina Autore: trittico69 |
Forum: Applicazioni Office Windows Risposte: 12 |
Barra Applicazioni tasto destro non attivo e ALTRO Autore: ricky53 |
Forum: Sistemi Operativi Windows Risposte: 6 |
Scelta da elenco a discesa che ne apre un altro Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 12 |
Visitano il forum: Nessuno e 31 ospiti