Ir para conteúdo
Fórum Script Brasil

Bruno Luigi

Membros
  • Total de itens

    2
  • Registro em

  • Última visita

Sobre Bruno Luigi

Bruno Luigi's Achievements

0

Reputação

  1. Olá, estou usando um código VBA para pegar uma informação de uma página web. O código VBA segue os seguintes passos: 1. Abre uma página web (a página default mostra os dados para a data de ontem 11/04/2018) 2. Preenche o campo de data com o valor 09/04/20214 3. Clica no botão OK 4. Pega um valor da página que foi carregada depois do clique no botão OK O problema é que o valor retornado não é o valor que foi atualizado depois do clique do botão e sim o valor que já estava na página default. A página mostrada no IE está com o valor atualizado mas o retorno do código tem o valor antigo. O código é de novato e que adaptou a partir de buscas na internet. Obrigado pela ajuda. Dim IE As Object Dim objElement As Object Dim objColletion1 As Object Dim objColletion2 As Object Dim x As Object Dim y As Object Dim i As Long 'Create Internet Explorer object Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True 'IE.navigate "http://www.bmfbovespa.com.br/pt_br/servicos/market-data/consultas/mercado-de-derivativos/contratos-em-aberto/por-tipo-de-participante/" IE.navigate "http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-tipo-de-participante-ptBR.asp" sleep (5000) 'wait 5 seconds to load web page Set objColletion1 = IE.document.getelementsbytagname("input") 'set field in a object i = 0 While i < objColletion1.Length 'try to find out field named "dData1" If objColletion1(i).Name = "dData1" Then ' set the date objColletion1(i).Value = "09/04/2018" 'a date before today End If i = i + 1 Wend Set objColletion2 = IE.document.getelementsbytagname("button") 'set the buttons on page i = 0 While i < objColletion2.Length 'try to fid out the button to submit If objColletion2(i).Type = "submit" And objColletion2(i).Name = "" Then 'OK button found Set objElement = objColletion2(i) End If i = i + 1 Wend objElement.Click 'OK button clicked sleep (5000) 'wait to load web page For Each x In IE.document.body.getelementsbytagname("table") 'search for a expected value If InStr(x.innertext, "MERCADO FUTURO DE DÓLAR") > 0 Then For Each y In x.getelementsbytagname("tr") If InStr(y.innertext, "Inv. Não Residente") > 0 Then MsgBox y.getelementsbytagname("td")(1).innertext End If Next y End If Next x Set IE = Nothing Set objElement = Nothing Set objColletion1 = Nothing Set objColletion2 = Nothing Bruno.
  2. Olá, estou usando um código VBA para pegar uma informação de uma página web. O código VBA segue os seguintes passos: 1. Abre uma página web (a página default mostra os dados para a data de ontem 11/04/2018) 2. Preenche o campo de data com o valor 09/04/20214 3. Clica no botão OK 4. Pega um valor da página que foi carregada depois do clique no botão OK O problema é que o valor retornado não é o valor que foi atualizado depois do clique do botão e sim o valor que já estava na página default. A página mostrada no IE está com o valor atualizado mas o retorno do código tem o valor antigo. O código é de novato e que adaptou a partir de buscas na internet. Obrigado pela ajuda. Dim IE As Object Dim objElement As Object Dim objColletion1 As Object Dim objColletion2 As Object Dim x As Object Dim y As Object Dim i As Long 'Create Internet Explorer object Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True 'IE.navigate "http://www.bmfbovespa.com.br/pt_br/servicos/market-data/consultas/mercado-de-derivativos/contratos-em-aberto/por-tipo-de-participante/" IE.navigate "http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-tipo-de-participante-ptBR.asp" sleep (5000) 'wait 5 seconds to load web page Set objColletion1 = IE.document.getelementsbytagname("input") 'set field in a object i = 0 While i < objColletion1.Length 'try to find out field named "dData1" If objColletion1(i).Name = "dData1" Then ' set the date objColletion1(i).Value = "09/04/2018" 'a date before today End If i = i + 1 Wend Set objColletion2 = IE.document.getelementsbytagname("button") 'set the buttons on page i = 0 While i < objColletion2.Length 'try to fid out the button to submit If objColletion2(i).Type = "submit" And objColletion2(i).Name = "" Then 'OK button found Set objElement = objColletion2(i) End If i = i + 1 Wend objElement.Click 'OK button clicked sleep (5000) 'wait to load web page For Each x In IE.document.body.getelementsbytagname("table") 'search for a expected value If InStr(x.innertext, "MERCADO FUTURO DE DÓLAR") > 0 Then For Each y In x.getelementsbytagname("tr") If InStr(y.innertext, "Inv. Não Residente") > 0 Then MsgBox y.getelementsbytagname("td")(1).innertext End If Next y End If Next x Set IE = Nothing Set objElement = Nothing Set objColletion1 = Nothing Set objColletion2 = Nothing Bruno.
×
×
  • Criar Novo...