Moderatori: Anthony47, Flash30005
Next tdtd
I = I + 1: J = 0
'Inizio Righe Aggiunte:
myid = trtr.ID
If Len(myid) > 8 Then
myHL = "http://www.diretta.it/partita/" & Replace(myid, "g_1_", "", , , vbTextCompare) & "/#informazioni-partita"
ActiveSheet.Hyperlinks.Add Anchor:=Cells(I, Columns.Count).End(xlToLeft).Offset(0, 1), _
Address:=myHL, TextToDisplay:=myHL
End If
'fine aggiunte
Next trtr
I = I + 2
Next myItm
I = I + 1: J = 0
'Inizio Righe Aggiunte:
myid = trtr.ID
If Len(myid) > 8 Then
myHL = "http://www.diretta.it/partita/" & Replace(myid, "g_1_", "", , , vbTextCompare) & "/#statistiche-partite;1"
If Cells(I, 2) = "Finale" Then
' ActiveSheet.Hyperlinks.Add Anchor:=Cells(I, Columns.Count).End(xlToLeft).Offset(0, 1), Address:=myHL, TextToDisplay:=myHL
ActiveSheet.Hyperlinks.Add Anchor:=Cells(I, 7), Address:=myHL, TextToDisplay:=myHL
End If
End If
'fine aggiunte
Next trtr
If Cells(riga, 7) <> "" Then
KK = 0: I = 0 '<<< AGGIUNGERE
myURL = (Sheets("Foglio2").Cells(riga, 7))
Sub GetWebTab2Param(lUrl)
Dim IE As Object, F As Long
Dim myRColl, myDColl, KK As Long, I As Long, J As Long, myColl, myR, myTD
'
''myURL = "http://www.statistichesulcalcio.com/mainstats/italia/Serie-A_71/anno_117.html" '<<<<
myurl = lUrl
Set IE = CreateObject("InternetExplorer.Application")
'
With IE
.navigate myurl
.Visible = True
Do While .Busy: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
myStart = Timer 'attesa addizionale
Do
DoEvents
If Timer > myStart + 2 Or Timer < myStart Then Exit Do
Loop
'Leggi le tabelle su foglio5 (su un nuovo foglio)
'Worksheets.Add '<<<<<1 -Nuovo foglio
''Application.Goto (Sheets("Foglio2").Range("A1")) '<<<<<2 -Foglio esistente
''Cells.Clear
Set myColl = IE.Document.getElementsbyTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tdtd In trtr.Cells
Cells(I + 1, J + 1) = tdtd.innertext
J = J + 1
Next tdtd
I = I + 1: J = 0
Next trtr
I = I + 2
Next myItm
'Legge le tabelle dentro gli iframe:
Set myColl = IE.Document.getElementsbyTagName("iframe")
For F = 0 To myColl.Length - 1
If Left(myColl(F).ID, 7) = "myframe" Then
Set my2coll = myColl(F).contentDocument.getElementsbyTagName("table")
For Each myItm In my2coll
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
Set myRColl = myItm.getElementsbyTagName("tr")
For Each myR In myRColl
Set myDColl = myR.getElementsbyTagName("td")
For Each myTD In myDColl
Cells(I + 1, J + 1) = myTD.innertext
J = J + 1
Next myTD
I = I + 1: J = 0
Next myR
I = I + 2
Next myItm
End If
Next F
'
Cells.WrapText = False
Range("A1").Select
'
'Stop 'Vedi testo
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Sub call1()
Sheets("Foglio1").Select '<<< Il foglio su cui si fara' l'importazione
Cells.ClearContents 'NB: Il fofglio SARA' AZZERATO senza preavviso
Call GetWebTab2Param("http://www.sisal.it/virtual-race/archivio-gare")
Cells.WrapText = False
'Seconda importazione
Sheets("Foglio2").Select '<<< Il foglio su cui si fara' l'importazione
Cells.ClearContents 'NB: Il fofglio SARA' AZZERATO senza preavviso
Call GetWebTab2Param("http://www.sisal.it/altroUrl")
Cells.WrapText = False
'
'altri Blocchi analoghi
End Sub
Sub GetWebTab2ParamZ1(lUrl)
Dim IE As Object, F As Long
Dim cTdCnt As Long
Dim myRColl, myDColl, KK As Long, I As Long, J As Long, myColl, myR, myTD
'
myurl = lUrl
Set IE = CreateObject("InternetExplorer.Application")
'
'With IE
IE.navigate myurl
IE.Visible = True
reLoop:
Do While IE.busy: DoEvents: Loop 'Attesa not busy
Do While IE.readystate <> 4: DoEvents: Loop 'Attesa documento
'End With
'
myStart = Timer 'attesa addizionale
Do
DoEvents
If Timer > myStart + 2 Or Timer < myStart Then Exit Do
Loop
'Specifico della versione Z1 >>>:
Set myTD = IE.document.getElementsByTagName("TD")
If myTD.Length = cTdCnt Then GoTo noLoop
cTdCnt = myTD.Length
On Error Resume Next
IE.document.getElementById("tournament-page-results-more").getElementsByTagName("a")(0).Click
On Error GoTo 0
myStart = Timer 'attesa javascript
Do
DoEvents
If Timer > myStart + 4 Or Timer < myStart Then Exit Do
Loop
GoTo reLoop
'<<< Fine parte specifica
'
noLoop:
'Leggi le tabelle su foglio5 (su un nuovo foglio)
'Worksheets.Add '<<<<<1 -Nuovo foglio
''Application.Goto (Sheets("Foglio2").Range("A1")) '<<<<<2 -Foglio esistente
''Cells.Clear
Set myColl = IE.document.getElementsByTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tdtd In trtr.Cells
Cells(I + 1, J + 1) = tdtd.innertext
J = J + 1
Next tdtd
I = I + 1: J = 0
Next trtr
I = I + 2
Next myItm
'Legge le tabelle dentro gli iframe:
Set myColl = IE.document.getElementsByTagName("iframe")
For F = 0 To myColl.Length - 1
If Left(myColl(F).ID, 7) = "myframe" Then
Set my2coll = myColl(F).contentDocument.getElementsByTagName("table")
For Each myItm In my2coll
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
Set myRColl = myItm.getElementsByTagName("tr")
For Each myR In myRColl
Set myDColl = myR.getElementsByTagName("td")
For Each myTD In myDColl
Cells(I + 1, J + 1) = myTD.innertext
J = J + 1
Next myTD
I = I + 1: J = 0
Next myR
I = I + 2
Next myItm
End If
Next F
'
Cells.WrapText = False
Range("A1").Select
'
'Stop 'Vedi testo
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Sub GetWebTab2()
Dim IE As Object, F As Long
Dim myRColl, myDColl, KK As Long, I As Long, J As Long, myColl, myR, myTD
'
myURL = "https://www.betexplorer.com/football/italy/serie-a/results/" '<<<<
Set IE = CreateObject("InternetExplorer.Application")
'
With IE
.navigate myURL
.Visible = True
Do While .Busy: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
myStart = Timer 'attesa addizionale
Do
DoEvents
If Timer > myStart + 2 Or Timer < myStart Then Exit Do
Loop
'Leggi le tabelle su foglio5 (su un nuovo foglio)
'Worksheets.Add '<<<<<1 -Nuovo foglio
Application.Goto (Sheets("Foglio1").Range("A1")) '<<<<<2 -Foglio esistente
Cells.Clear
Set myColl = IE.Document.getElementsbyTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tdtd In trtr.Cells
Cells(I + 1, J + 1) = tdtd.innertext
J = J + 1
Next tdtd
I = I + 1: J = 0
Next trtr
I = I + 2
Next myItm
'Legge le tabelle dentro gli iframe:
Set myColl = IE.Document.getElementsbyTagName("iframe")
For F = 0 To myColl.Length - 1
If Left(myColl(F).ID, 7) = "myframe" Then
Set my2coll = myColl(F).contentDocument.getElementsbyTagName("table")
For Each myItm In my2coll
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
Set myRColl = myItm.getElementsbyTagName("tr")
For Each myR In myRColl
Set myDColl = myR.getElementsbyTagName("td")
For Each myTD In myDColl
Cells(I + 1, J + 1) = myTD.innertext
J = J + 1
Next myTD
I = I + 1: J = 0
Next myR
I = I + 2
Next myItm
End If
Next F
'
Cells.WrapText = False
Range("A1").Select
'
'Stop 'Vedi testo
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Usando come browser InternetExplorer?dal web mi fa vedere tutto
Ma quella macro lavora tramite InternetExplorer, che invece oggi (non so da quanto tempo) non visualizza le quotazioni.microsoft edge
Torna a Applicazioni Office Windows
Perchè l'importazione dati con Selenium non fuziona? Autore: aggittoriu |
Forum: Applicazioni Office Windows Risposte: 7 |
copia di dati da un file chiuso e elaborazione Autore: luca62 |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 49 ospiti