Excel e gli applicativi Microsoft Office prendere v alori in una table con api get

Login Registrati
Stai vedendo 15 articoli - dal 1 a 15 (di 15 totali)
  • Autore
    Articoli
  • #53353 Score: 0 | Risposta

    sal

      https://www.extrazioni.it/estrazioni...equenti-lotto/
      prendere valori in una table: ambi frequenti

      se possibile con una  api get.
      grazie

      #53354 Score: 0 | Risposta

      LukeReds
      Partecipante
        19 pts

        ciao

        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

        #53362 Score: 0 | Risposta

        sal

          Ambi frequenti Lotto

          questo e quello corretto

          #53363 Score: 0 | Risposta

          LukeReds
          Partecipante
            19 pts

            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

            #53366 Score: 0 | Risposta

            sal

              a me serve con una api web

              grazie comunque per il consiglio

              #53367 Score: 0 | Risposta

              Oscar
              Partecipante
                45 pts

                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 Sub
                #53370 Score: 0 | Risposta

                sal

                  grazie oscar!

                  ma visto che IE non   sarà pio supportato, puoi modificare con una API GET il tuo codice?

                  grazie

                  #53373 Score: 0 | Risposta

                  Oscar
                  Partecipante
                    45 pts

                    sal ha scritto:

                    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à

                    #53383 Score: 0 | Risposta

                    Oscar
                    Partecipante
                      45 pts

                      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 Sub
                      #53384 Score: 0 | Risposta

                      sal

                        oscar non roesco a fare la copia, mi dice:

                        [⚠️ Suspicious Content]

                        me lo puoi mandare su gss.italy[at]iol.it

                        grazie

                         

                         

                         

                        #53385 Score: 0 | Risposta

                        LukeReds
                        Partecipante
                          19 pts

                          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 Sub
                          #53387 Score: 0 | Risposta

                          Oscar
                          Partecipante
                            45 pts

                            sal ha scritto:

                            oscar 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.
                            #53389 Score: 0 | Risposta

                            sal

                              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.

                              #53390 Score: 0 | Risposta

                              Oscar
                              Partecipante
                                45 pts

                                sal ha scritto:

                                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 Sub

                                uesta

                                Allegati:
                                You must be logged in to view attached files.
                                #53392 Score: 0 | Risposta

                                LukeReds
                                Partecipante
                                  19 pts

                                  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
                                Login Registrati
                                Stai vedendo 15 articoli - dal 1 a 15 (di 15 totali)
                                Rispondi a: prendere v alori in una table con api get
                                Gli allegati sono permessi solo ad utenti REGISTRATI
                                Le tue informazioni: