|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Feb 2014
Messaggi: 201
|
[EXCEL VBA] Estrarre dati da sito web
Salve a tutti ragazzi del forum, vi scrivo per chiedervi se qualcuno che sa programmare in VBA mi aiuterebbe ad estrarre dati da questa pagina web: http://www.oddsportal.com/soccer/eng...gue/standings/
PREMESSA: Ho scritto una formula in excel che dentro una cella mi crea un link come quello, ed io cliccandoci vado diretto alla pagina web. Ora ciò che vorrei fare è estrarre i dati scritti su HOME e su AWAY e riportarli in un foglio di calcolo. Ho già provato tramite una Query ma non me li estrae, perché non li vede, vede solo la classifica totale, oppure facendo: "Dati" >> "da Web", stessa cosa, non mi permette di copiarli. Ho anche provato registrando una macro, ma niente ancora... Credo resti solo il VBA, ma io non lo conosco come linguaggio di programmazione, mi potete aiutare? Grazie infinite |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Feb 2014
Messaggi: 201
|
Salve a tutti, sono riuscito nell'intento grazie al registra macro e questo è il risultato:
Codice:
Sub EstrDati_a_casa_oggi()
'
' EstrDati_a_casa_oggi Macro
'
'
ActiveWorkbook.Queries.Add Name:="Tabella1", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Origine = Web.Page(Web.Contents(""http://www.oddsportal.com/ajax-standings/tab/table/table_sub/home/t/jZWp0BeC/ts/f9KQrnNJ/""))," & Chr(13) & "" & Chr(10) & " Data0 = Origine{0}[Data]," & Chr(13) & "" & Chr(10) & " #""Modificato tipo"" = Table.TransformColumnTypes(Data0,{{""#"", Int64.Type}, {""Team"", type text}, {""MP"", Int64.Type}, {""W"", Int64.Type}, {""D"", Int64.Type}, {""L"", Int64.Type}, {""G"", " & _
"type text}, {""Pts"", Int64.Type}, {""Form"", type text}})," & Chr(13) & "" & Chr(10) & " #""Rimosse colonne"" = Table.RemoveColumns(#""Modificato tipo"",{""#"", ""MP"", ""G"", ""Pts"", ""Form""})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Rimosse colonne"""
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Tabella1" _
, Destination:=Range("$B$2")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [Tabella1]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Tabella1"
.Refresh BackgroundQuery:=False
End With
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Feb 2014
Messaggi: 201
|
sono riuscito a risolvere guardando questo video https://www.youtube.com/watch?v=ZJ30U0qw850 e creando perciò una Web Query Dinamica
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 08:53.



















