› Excel e gli applicativi Microsoft Office › prendere v alori in una table con api get
-
AutoreArticoli
-
https://www.extrazioni.it/estrazioni...equenti-lotto/
prendere valori in una table: ambi frequentise possibile con una api get.
grazieciao
non è chiaro cosa ti serva, dov'è la table di cui parli? in qualche sito web? Allwega il link di questo sito,, in caso, Il link che hai inviato per è, a mio parere, inutile ai fini della risoluzione del problema
questo e quello corretto
sei fortunato, puoi caricare i dati della tabella con le power query, senza bisogno di codice per web scraping
Dati - da web (excel >= 2010) - inserisci l'url e segui le indicaizoni
a me serve con una api web
grazie comunque per il consiglio
Prova così poi se c'è qualcosa da modificare lo puoi fare anche tu
Option Explicit Sub GetTab() Dim myURL As String Dim ie As Variant Dim myStart As Variant Dim mycoll As Variant Dim myItm As Variant Dim trtr As Variant Dim tdtd As Variant Dim I, J As Integer Application.ScreenUpdating = False myURL = "https://www.extrazioni.it/estrazioni-del-lotto/ambi-frequenti-lotto" Set ie = CreateObject("InternetExplorer.Application") With ie .navigate myURL .Visible = False Do While .Busy: DoEvents: Loop Do While .readyState <> 4: DoEvents: Loop End With myStart = Timer Do DoEvents If Timer > myStart + 2 Or Timer < myStart Then Exit Do Loop Sheets(1).Select 'Cells.Clear Set mycoll = ie.document.getElementsByTagName("TABLE") For Each myItm In mycoll 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 ie.Quit Set ie = Nothing End Subgrazie oscar!
ma visto che IE non sarà pio supportato, puoi modificare con una API GET il tuo codice?
grazie
grazie oscar!
ma visto che IE non sarà pio supportato, puoi modificare con una API GET il tuo codice?
grazie
Ho già provato purtroppo non funziona con tutte le tabelle e con quel tipo di tabella che vuoi scaricare tu non funziona
Ma poi se per il momento ti funziona usalo così poi si vedrà
Prova questo
Option Explicit Sub Ambi_Frequenti() Application.ScreenUpdating = False Dim xName As Name Dim xlDeleteCells As Variant With ActiveSheet.QueryTables.Add(Connection:= _ "URL;https://www.xlotto.it/lotto/tabellambf.asp", Destination:=Range("$A$1")) .Name = "tabellambf" .RefreshStyle = xlDeleteCells .WebFormatting = xlWebFormattingNone .Refresh BackgroundQuery:=False End With For Each xName In Application.ActiveWorkbook.Names xName.Delete Next End Suboscar non roesco a fare la copia, mi dice:
[⚠️ Suspicious Content]
me lo puoi mandare su gss.italy[at]iol.it
grazie
se con api web intendi un programma di web scraping
Sub LottoX() Dim driver As Object Dim tb As Object Dim tbs As Object Dim frame As Object Dim frames As Object Set driver = CreateObject("Selenium.ChromeDriver") Cells.Clear 'Driver.AddArgument ("--headless") driver.Start driver.get "https://www.extrazioni.it/" driver.Wait 3000 Set frames = driver.FindElementsByTag("iframe") For Each frame In driver.FindElementsByTag("iframe") If frame.Attribute("title") = "Finestra di consenso" Then driver.SwitchToFrame frame Exit For End If Next frame ' SISTEMARE QUESTO WAIT driver.Wait 15000 driver.FindElementByTag("svg").Click driver.SwitchToDefaultContent Set tb = driver.FindElementByClass("lotto-box") tb.AsTable.ToExcel (Cells(1, 1)) End Suboscar non roesco a fare la copia, mi dice:
[
Suspicious Content]
me lo puoi mandare su gss.italy[at]iol.it
grazie
Dipende dalla versione di Excel che hai ti allego il File quando lo apri viene convertito in automatico
Allegati:
You must be logged in to view attached files.ho risolto...grazie funziona a meraviglia!
ma invece dio fare il print su un foglio di excel si puo salvare il risultato in in file txt per esempio in c:\mydir\nome file.txt
grazie ancora.
ho risolto...grazie funziona a meraviglia!
ma invece dio fare il print su un foglio di excel si puo salvare il risultato in in file txt per esempio in c:\mydir\nome file.txt
grazie ancora.
Si che si puo deve comunque essere scaricata e salvata in Txt
Prova anche questa
Option Explicit Sub GetTab() Application.ScreenUpdating = False Dim myURL As String Dim ie As Variant Dim myStart As Variant Dim mycoll As Variant Dim myItm As Variant Dim trtr As Variant Dim tdtd As Variant Dim I, J As Integer Dim Aggiusta As String Dim Table myURL = "https://www.extrazioni.it/estrazioni-del-lotto/ambi-frequenti-lotto" Set Table = CreateObject("InternetExplorer.Application") With Table .navigate myURL .Visible = False Do While .Busy: DoEvents: Loop Do While .readyState <> 4: DoEvents: Loop End With myStart = Timer Do DoEvents If Timer > myStart + 2 Or Timer < myStart Then Exit Do Loop Sheets(1).Select Cells.Clear Set mycoll = Table.document.getElementsByTagName("TABLE") For Each myItm In mycoll For Each trtr In myItm.Rows For Each tdtd In trtr.Cells If Len(tdtd.innerText) = 2 Then Aggiusta = "" Else Aggiusta = "'" End If Cells(I + 1, J + 1) = Aggiusta & tdtd.innerText If tdtd.innerText = "Frequenza" Then J = J + 2 Else J = J + 1 End If Next tdtd I = I + 1: J = 0 Next trtr I = I + 1 Next myItm Table.Quit Set Table = Nothing Range("C2:G23").HorizontalAlignment = xlCenter End Subuesta
Allegati:
You must be logged in to view attached files.oer salvare un foglio cone txt
Sub SalvaComeTXT() Dim percorso As String ' Percorso e nome file di destinazione percorso = "C:\Users\Lucar\Desktop\file.txt" ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:=percorso, _ FileFormat:=xlText, _ CreateBackup:=False ActiveWorkbook.Close SaveChanges:=False End Sub -
AutoreArticoli
