Guest Zangado Posted March 22, 2017 Share Posted March 22, 2017 (edited) macro que pega o resultado da x-loterias Sub Atualiza_da_internet2() espera = 10000 Dim Lot(1 To 7, 1 To 3) As String Lot(1, 1) = "quina/": Lot(1, 2) = "qnConcursoData" Lot(2, 1) = "timemania/": Lot(2, 2) = "tmConcursoData" Lot(3, 1) = "duplasena/": Lot(3, 2) = "dsConcursoData" Lot(5, 1) = "megasena/": Lot(5, 2) = "msConcursoData" Lot(6, 1) = "lotomania/": Lot(6, 2) = "lmConcursoData" Lot(7, 1) = "lotofacil/": Lot(7, 2) = "lfConcursoData" N = 6'loteria Dim iEp As InternetExplorer Set iEp = New InternetExplorer If Not iEp Is Nothing Then iEp.Quit Set iEp = New InternetExplorer iEp.Navigate "http://www.xloterias.com.br/" & Lot(N, 1) iEp.Visible = True ' espera até a pagina carregarcompletamente For nt = 1 To espera Do While iEp.Busy: Loop Next ' PULA PARA O CONCURSO ANTERIOR ' iEp.Document.getElementById("lblConcursoAnterior").getElementsByTagName("a")(0).FireEvent "onclick" ' espera até a pagina carregarcompletamente: For nj2 = 1 To espera While iEp.Busy Or iEp.ReadyState <> READYSTATE_COMPLETE: Wend Next 'DATA: concData = DateValue(Right(iEp.Document.all(Lot(N, 2)).innertext, 10)) 'NUMERO CONCURSO: conc = iEp.Document.all(Lot(N, 2)).getElementsByTagName("span")(0).innertext 'RESULTADO: resut = iEp.Document.getElementsByName("txtOrdemSorteio")(0).Value MsgBox conc & " - " & concData & " - " & resut iEp.Quit Set iEp = Nothing End Sub Edited March 22, 2017 by Zangado Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 22, 2017 Share Posted March 22, 2017 @Crazy Rabbit que tal incrementar suas planilhas com esta ótima solução do amigo Edcronos2. Atualizar aquele montão de resultados automaticamente. Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 22, 2017 Share Posted March 22, 2017 1 minuto atrás, Crazy Rabbit disse: Vou testar primeiro. OK Ok. Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 22, 2017 Share Posted March 22, 2017 Amigo @edcronos2 Por favor, você não tem algum exemplo pronto na planilha? Se tiver e puder me ceder, eu te agradeço. Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 22, 2017 Share Posted March 22, 2017 7 minutos atrás, cerealkiller disse: Amigo @edcronos2 Por favor, você não tem algum exemplo pronto na planilha? Se tiver e puder me ceder, eu te agradeço. eu desisti de fazer, então parei aí mas a parte que pega do site está completa é só incrementar para passar para a planilha, só serve mesmo para manter a planilha atualizada tipo verifica o ultimo concurso da planilha pega o ultimo da pagina comparar , se o da planilha for menor pular para a diferença de linhas planilha=50 site=60 60-50=10 ultima linha da planilha mais 10 cola o ultimo resultado, e vai decrementando a linha e pulando para o sorteio anterior as dezenas são separadas por espaço então pode usar o split para separar Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 22, 2017 Share Posted March 22, 2017 7 minutos atrás, edcronos2 disse: eu desisti de fazer, então parei aí mas a parte que pega do site está completa é só incrementar para passar para a planilha, só serve mesmo para manter a planilha atualizada tipo verifica o ultimo concurso da planilha pega o ultimo da pagina comparar , se o da planilha for menor pular para a diferença de linhas planilha=50 site=60 60-50=10 ultima linha da planilha mais 10 cola o ultimo resultado, e vai decrementando a linha e pulando para o sorteio anterior as dezenas são separadas por espaço então pode usar o split para separar Ok. obrigado Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 22, 2017 Share Posted March 22, 2017 para passar para a planilha pode fazer assim bb = conc & " " & concData & " " & resut ss = Split(bb, " ") Linha = 1 Range(Cells(Linha, 1), Cells(Linha, UBound(ss))) = ss Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 22, 2017 Share Posted March 22, 2017 26 minutos atrás, cerealkiller disse: Ok. obrigado olha vou montar uma macro mas bem simples serm nenhum extra a planilha já tem que estar com algum resultado Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 22, 2017 Share Posted March 22, 2017 é só colocar em alguma planilha escolher a loteria e rodar no caso vai colar os resultados na aba ativa a partir da coluna A se quiser testar é só escrever algum numero de concurso inferior ao ultimo na ca coluna "A" e rodar a macro Sub Atualiza_da_internet2() espera = 10000 Dim Lot(1 To 7, 1 To 3) As String 'Lotomania 1697, veja as dezenas do dia 30/09/16 Dim iEp As InternetExplorer Set iEp = New InternetExplorer If Not iEp Is Nothing Then iEp.Quit Set iEp = New InternetExplorer site = "http://www.xloterias.com.br/" Lot(1, 1) = "quina/": Lot(1, 2) = "qnConcursoData" Lot(2, 1) = "timemania/": Lot(2, 2) = "tmConcursoData" Lot(3, 1) = "duplasena/": Lot(3, 2) = "dsConcursoData" Lot(5, 1) = "megasena/": Lot(5, 2) = "msConcursoData" Lot(6, 1) = "lotomania/": Lot(6, 2) = "lmConcursoData" Lot(7, 1) = "lotofacil/": Lot(7, 2) = "lfConcursoData" N = 6 iEp.Navigate "http://www.xloterias.com.br/" & Lot(N, 1) iEp.Visible = True 'False ' For nt = 1 To espera Do While iEp.Busy: Loop ' espera até a pagina carregarcompletamente Next ' PULA PARA O CONCURSO ANTERIOR ' iEp.Document.getElementById("lblConcursoAnterior").getElementsByTagName("a")(0).FireEvent "onclick" For nj2 = 1 To espera While iEp.Busy Or iEp.ReadyState <> READYSTATE_COMPLETE: Wend Next Dim conc As Long, l As Long, cc As Long, llc As Long conc = iEp.Document.all(Lot(N, 2)).getElementsByTagName("span")(0).innertext l = Cells(Rows.Count, 1).End(xlUp).Row + 1 cc = Cells(l - 1, 1).Value2 llc = conc - cc - 1 MsgBox llc If llc > 0 Then For ll = l + llc To l Step -1 concData = DateValue(Right(iEp.Document.all(Lot(N, 2)).innertext, 10)) conc = iEp.Document.all(Lot(N, 2)).getElementsByTagName("span")(0).innertext resut = iEp.Document.getElementsByName("txtOrdemSorteio")(0).Value ss = Split(conc & " " & concData & " " & resut, " ") Range(Cells(ll, 1), Cells(ll, UBound(ss) + 1)).Value2 = ss 'Split(bb, " ") iEp.Document.getElementById("lblConcursoAnterior").getElementsByTagName("a")(0).FireEvent "onclick" For nt = 1 To espera While iEp.Busy Or iEp.ReadyState <> READYSTATE_COMPLETE: Wend Do While iEp.Busy: Loop ' espera até a pagina carregarcompletamente Next Next End If iEp.Quit Set iEp = Nothing End Sub Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 22, 2017 Share Posted March 22, 2017 34 minutos atrás, edcronos2 disse: é só colocar em alguma planilha escolher a loteria e rodar no caso vai colar os resultados na aba ativa a partir da coluna A se quiser testar é só escrever algum numero de concurso inferior ao ultimo na ca coluna "A" e rodar a macro Sub Atualiza_da_internet2() espera = 10000 Dim Lot(1 To 7, 1 To 3) As String 'Lotomania 1697, veja as dezenas do dia 30/09/16 Dim iEp As InternetExplorer Set iEp = New InternetExplorer If Not iEp Is Nothing Then iEp.Quit Set iEp = New InternetExplorer site = "http://www.xloterias.com.br/" Lot(1, 1) = "quina/": Lot(1, 2) = "qnConcursoData" Lot(2, 1) = "timemania/": Lot(2, 2) = "tmConcursoData" Lot(3, 1) = "duplasena/": Lot(3, 2) = "dsConcursoData" Lot(5, 1) = "megasena/": Lot(5, 2) = "msConcursoData" Lot(6, 1) = "lotomania/": Lot(6, 2) = "lmConcursoData" Lot(7, 1) = "lotofacil/": Lot(7, 2) = "lfConcursoData" N = 6 iEp.Navigate "http://www.xloterias.com.br/" & Lot(N, 1) iEp.Visible = True 'False ' For nt = 1 To espera Do While iEp.Busy: Loop ' espera até a pagina carregarcompletamente Next ' PULA PARA O CONCURSO ANTERIOR ' iEp.Document.getElementById("lblConcursoAnterior").getElementsByTagName("a")(0).FireEvent "onclick" For nj2 = 1 To espera While iEp.Busy Or iEp.ReadyState <> READYSTATE_COMPLETE: Wend Next Dim conc As Long, l As Long, cc As Long, llc As Long conc = iEp.Document.all(Lot(N, 2)).getElementsByTagName("span")(0).innertext l = Cells(Rows.Count, 1).End(xlUp).Row + 1 cc = Cells(l - 1, 1).Value2 llc = conc - cc - 1 MsgBox llc If llc > 0 Then For ll = l + llc To l Step -1 concData = DateValue(Right(iEp.Document.all(Lot(N, 2)).innertext, 10)) conc = iEp.Document.all(Lot(N, 2)).getElementsByTagName("span")(0).innertext resut = iEp.Document.getElementsByName("txtOrdemSorteio")(0).Value ss = Split(conc & " " & concData & " " & resut, " ") Range(Cells(ll, 1), Cells(ll, UBound(ss) + 1)).Value2 = ss 'Split(bb, " ") iEp.Document.getElementById("lblConcursoAnterior").getElementsByTagName("a")(0).FireEvent "onclick" For nt = 1 To espera While iEp.Busy Or iEp.ReadyState <> READYSTATE_COMPLETE: Wend Do While iEp.Busy: Loop ' espera até a pagina carregarcompletamente Next Next End If iEp.Quit Set iEp = Nothing End Sub Vou tentar aqui pois ainda estou aprendendo a mexer em Excel, muito obrigado Edcronos2 Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 23, 2017 Share Posted March 23, 2017 alguem conseguiu testar a macro? Quote Link to comment Share on other sites More sharing options...
cerealkiller Posted March 24, 2017 Share Posted March 24, 2017 @edcronos2, eis ai a minha dificuldade. Sou totalmente noob Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 24, 2017 Share Posted March 24, 2017 Agora, cerealkiller disse: @edcronos2, eis ai a minha dificuldade. Sou totalmente noob então é melhor eu colocar no conferidor que postei aqui Quote Link to comment Share on other sites More sharing options...
Guest Zangado Posted March 24, 2017 Share Posted March 24, 2017 de qualquer forma vai ser outra hora pq tenho que levantar bem cedo hoje Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.