Jump to content

macro que pega o resultado da x-loterias


Guest Zangado

Recommended Posts

Guest Zangado

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 by Zangado
Link to comment
Share on other sites

Guest Zangado
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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest Zangado

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 

 

Link to comment
Share on other sites

Guest Zangado
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

Link to comment
Share on other sites

Guest Zangado

é 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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...