Scrivo perchè da oggi ho un problema su una macro con web query che fino a poco tempo fa non mi dava problemi.
L'URL dal quale voglio scaricare i dati è questo: http://www.eurocupbasketball.com/eurocu ... code=U2015
Scaricando i dati con la macro sottostante, non solo venivano scaricate le tabelle che vedete (della sezione Boxscore), ma anche quella che si vede nella sezione Play By Play, che in teoria hanno questo URL: http://www.eurocupbasketball.com/eurocu ... playbyplay , ma che in realtà non serve specificare.
Ecco il codice con cui scaricavo tutto.
- Codice: Seleziona tutto
Sub Scarica()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.eurocupbasketball.com/eurocup/games/results/showgame?gamecode=301&seasoncode=U2015", Destination:=Range("$A$1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingRTF
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Facendo girare questo codice, la tabella presente nella sezione play by play non viene scaricata. In effetti, mentre con IE questa tabella la vedo tranquillamente, se apro da Excel->Dati->DaWeb l'indirizzo specificato, da quel browser che mi si apre per scaricare in maniera guidata i dati, la tabella non si carica (prima si caricava).
Cercando un po' su questo forum (si, si, lo so, grazie, no no non c'è bisogno, davvero...) ho trovato questo codice di Antony, che però non risolve il problema putroppo
- Codice: Seleziona tutto
Sub GetTabs()
'
myURL = "http://www.eurocupbasketball.com/eurocup/games/results/showgame?gamecode=301&seasoncode=U2015#!playbyplay"
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 un foglio
'Worksheets.Add 'NUOVO
Application.Goto (Sheets("Foglio5").Range("A1")) '<<<< Foglio specifico
Cells.Clear
Set myColl = IE.document.getElementsByTagName("TABLE")
For Each myItm In myColl '***1
'Set myitm = mycoll(4) '***2
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 + 1
Next myItm '***1
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Che dire... ragazzi, qualcuno riesce a darmi una mano?
Grazie!