F.R.I.D.A.Y.

로또 번호 불러오기 본문

DEV/.Net

로또 번호 불러오기

F.R.I.D.A.Y. 2018. 6. 4. 14:16
반응형


Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Using web As New Net.WebClient
            With web
                .Encoding = System.Text.Encoding.Default
                Dim str As String = Nothing
                Dim list As New List(Of String)
                For i = 1 To 809
                    Dim url As String = $"http://nlotto.co.kr/gameResult.do?method=byWin&drwNo={i}"
                    str = .DownloadString(url)
                    str = Mid(str, InStr(str, "<p class=""number"">") + Len("<p class=""number"">"))
                    str = Split(str, "/></span>")(0)
                    'MsgBox(str)
                    Dim temp() As String
                    temp = Split(str, Chr(13))
                    For k = 0 To temp.Count - 1
                        If InStr(temp(k), "img") >= 1 Then
                            temp(k) = Mid(temp(k), InStr(temp(k), "alt=") + "alt=".Length + 1)
                            temp(k) = Split(temp(k), "/>")(0)
                            temp(k) = Mid(temp(k), 1, InStr(temp(k), Chr(34)) - 1)
                            list.Add(temp(k))

                        End If
                    Next
                    str = $"{Format("000", i).ToString}회 : "
                    For k = 0 To list.Count - 1
                        str &= $"{list(k)} "
                    Next
                    list.Clear()
                    str &= Chr(13) & Chr(10)
                    My.Computer.FileSystem.WriteAllText("d:\lotto.txt", str, True)

                Next
                'RichTextBox2.Text = str


            End With

        End Using

    End Sub
End Class


Form1에서 그대로 가져다가 붙여넣으면 로또 번호를 1회차부터 809회차까지 불러옴.


728x90
반응형
Comments