조회수 올리기.7z

Dim WinHttp As New WinHttpRequest
Dim CID As String
Dim TotalCount As Integer

Private Sub Command1_Click()
    WinHttp.Open "POST", "http://nid.naver.com/nidlogin.login"
    WinHttp.SetRequestHeader "Referer", "https://nid.naver.com/nidlogin.login"
    WinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    WinHttp.Send "enctp=2&svctype=0&id=" & Text1 & "&pw=" & Text2
    
    If InStr(StrConv(WinHttp.ResponseBody, vbUnicode), "http://static.nid.naver.com/sso/cross-domain.nhn") Then
        Frame1.Enabled = False: Text1.Enabled = False: Text2.Enabled = False: Command1.Enabled = False
        Text3.Enabled = True: Command2.Enabled = True: Frame2.Enabled = True
    Else
        MsgBox "로그인에 실패하셨습니다.", vbCritical, "로그인 실패!"
    End If
End Sub

Private Sub Command2_Click()
    WinHttp.Open "GET", "http://cafe.naver.com/" & Text3
    WinHttp.Send
    WinHttp.WaitForResponse
    
    CID = Split(Split(StrConv(WinHttp.ResponseBody, vbUnicode), "g_sClubId = """)(1), """;")(0)
    
    WinHttp.Open "GET", "http://cafe.naver.com/MyCafeMyActivityAjax.nhn?clubid=" & CID & "&id=1340475718854"
    WinHttp.Send
    WinHttp.WaitForResponse
    
    If InStr(Utf82String(WinHttp.ResponseBody), "Permission Denied") = 0 Then
        Frame2.Enabled = False: Text3.Enabled = False: Command2.Enabled = False
        Frame4.Enabled = True: Label2.Enabled = True: Text5.Enabled = True
        Command3.Enabled = True: Command4.Enabled = True: Command5.Enabled = True: ListView1.Enabled = True
    Else
        MsgBox "카페 회원이 아닙니다.", vbCritical, "인증 실패!"
    End If
End Sub

Private Sub Command3_Click()
    ListView1.ListItems.Add , , CID
    ListView1.ListItems(ListView1.ListItems.Count).SubItems(1) = Text5
    ListView1.ListItems(ListView1.ListItems.Count).SubItems(2) = 0
End Sub

Private Sub Command4_Click()
    ListView1.ListItems.Remove ListView1.SelectedItem.Index
End Sub

Private Sub Command5_Click()
    If Command5.Caption = "시작" Then
        Timer1.Enabled = True
        Command5.Caption = "중지"
    Else
        Timer1.Enabled = False
        Command5.Caption = "시작"
    End If
End Sub

Private Sub Form_Load()
    ListView1.ColumnHeaders.Add , , "카페 번호", 2000
    ListView1.ColumnHeaders.Add , , "게시글 번호", 1400
    ListView1.ColumnHeaders.Add , , "반복 카운트", 2750
    Text2.Font = "Wingdings"
    Text2.PasswordChar = "l"
End Sub

Private Function Utf82String(ByRef data() As Byte) As String
 Dim objStream
 Dim strTmp As String
 Set objStream = CreateObject("ADODB.Stream")
 objStream.Charset = "utf-8"
 objStream.Mode = 3
 objStream.Type = 1
 objStream.Open
 objStream.Write data
 objStream.Flush
 objStream.Position = 0
 objStream.Type = 2
 strTmp = objStream.ReadText
 objStream.Close
 Set objStream = Nothing
 Utf82String = strTmp
End Function

Private Sub Timer1_Timer()
    For i = 1 To ListView1.ListItems.Count
        WinHttp.Open "GET", "http://cafe.naver.com/ArticleRead.nhn?clubid=" & CID & "&page=1&menuid=1&boardtype=L&articleid=" & ListView1.ListItems(i).SubItems(1) & "&referrerAllArticles=false"
        WinHttp.Send

        ListView1.ListItems(i).SubItems(2) = Int(ListView1.ListItems(i).SubItems(2)) + 1
        TotalCount = TotalCount + 1
        StatusBar1.Panels(2).Text = "총 반복 횟수 : " & TotalCount
    Next i
End Sub