Chamuanza Posted March 4, 2026 at 04:05 PM Report #635614 Posted March 4, 2026 at 04:05 PM (edited) Um bem Aja a todos Tenho uma rotina aplicada num projecto pessoal para ir buscar o "Ultimo Resultado" do EUROMIHHÕES ao site da Santa casa que tem funcionado bem. De ontem para hoje deixou de funcionar e aparece uma mensagem “System.Net.WebException: Pedido abortado:Não foi possível criar um canal seguro SSL/TLS em System.Net.HttpWebRequest.GetResponse() em TotoMilhoesNovo.frmSorteioNumerosEuromilhoes.butObterChaveEuromilhoes_Click(Object sender, EventArgs e) em D:\Copia_TotoMilhoesNovo\TotoMilhoesNovo\ frmSorteioNumerosEuromilhoes.vb:line 934” Nota Junto código da rotina Private Sub butObterChaveEuromilhoes_Click(sender As Object, e As EventArgs) Handles butObterChaveEuromilhoes.Click Dim oWebRequest As WebRequest Dim oWebResponse As WebResponse = Nothing Dim strBuffer As String = "" Dim objSR As StreamReader = Nothing Dim leitor As Object Dim ler As Boolean = False Dim valores As String = String.Empty Dim i As Integer = 0 Dim num_final As String = String.Empty Dim estrela_final As String = String.Empty 'conecta com o website Try oWebRequest = HttpWebRequest.Create("https://www.jogossantacasa.pt/web/SCCartazResult/euroMilhoes") oWebResponse = oWebRequest.GetResponse() 'Le a resposta do web site e armazena em uma stream objSR = New StreamReader(oWebResponse.GetResponseStream) strBuffer = objSR.ReadToEnd leitor = Split(strBuffer, vbNewLine) For Each linha In leitor If ler = True Then valores += linha.ToString + vbNewLine i += 1 End If 'If linha.Contains("Ordem Saída:") Then ' ler = True 'End If If linha.Contains("Chave") Then ler = True End If 'Altera o formato da data do sorteio para verificar se corresponde a data do sorteio que o Site apresenta Dim TestString As String = String.Format("{0:dd/MM/yyyy}", DataDateTimePicker.Value) ' Returns "Shipping List". aString = Replace(TestString, "-", "/") 'If linha.Contains("Data do Sorteio") And linha.Contains(aString) Then ' 'Obtem o valor da linha Retira caracteres a string ' Label17.Text = Trim(linha.ToString.Remove(34, 7)) ' ' Label15.Text = linha.ToString 'Else ' MsgBox("DATA NÃO CORRESPONDE AO SORTEIO", MsgBoxStyle.Information, "Data do Sorteio Incorreta") ' Exit Sub 'End If If linha.Contains("Data do Sorteio") Then If Not linha.Contains(aString) Then MsgBox("DATA NÃO CORRESPONDE AO SORTEIO", MsgBoxStyle.Information, "Data do Sorteio Incorreta") Exit Sub End If 'Obtem o valor da linha Retira caracteres a string Label17.Text = (linha.ToString) 'ove(34, 7)) End If If i > 8 Then ler = False End If 'If linha.Contains("Data do Sorteio") Then ' 'Obtem o valor da linha Retira caracteres a string ' Label17.Text = (linha.ToString.Remove(34, 7)) 'End If If i > 8 Then ler = False End If Next Catch ex As Exception MsgBox(ex.ToString) Finally objSR.Close() oWebResponse.Close() End Try 'Retira caracteres a string Label18.Text = Label17.Text.Remove(0, 6) Dim WC As New Net.WebClient Dim Rsp As String = WC.DownloadString("https://www.jogossantacasa.pt/web/SCCartazResult/euroMilhoes") Dim m As Match = Regex.Match(Rsp, "<li>(?<resultado>(?<num1>\d+) (?<num2>\d+) (?<num3>\d+) (?<num4>\d+) (?<num5>\d+) \+ (?<est1>\d+) (?<est2>\d+))</li>", RegexOptions.IgnoreCase) MsgBox("Data do Sorteio: " & aString & vbNewLine & vbNewLine & "Chave: " & m.Groups("resultado").ToString(), MsgBoxStyle.Information, "Obter Chave EuroMilhões da Santa Casa") ' MsgBox(vbNewLine & "Chave: " & m.Groups("resultado").ToString(), MsgBoxStyle.Information, "Obter Chave EuroMilhões da Santa Casa") 'Transfere on numeros para as caixas de texto NS1TextBox.Text = m.Groups("num1").ToString() NS2TextBox.Text = m.Groups("num2").ToString() NS3TextBox.Text = m.Groups("num3").ToString() NS4TextBox.Text = m.Groups("num4").ToString() NS5TextBox.Text = m.Groups("num5").ToString() ES1TextBox.Text = m.Groups("est1").ToString() ES2TextBox.Text = m.Groups("est2").ToString() End Sub Após clicar para obter os dados bloqueia na linha com o código "Finally objSR.Close()" e mensagem "A referência de objecto não foi definida como uma instância de um objecto." Agrdeço ajuda desde já Edited March 4, 2026 at 07:03 PM by Chamuanza Acrescentar dados
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now