• CSDN工具-CSDN博客登陆


    不知道这篇博文能不能发表出去,用第三方的软件登陆CSDN会不会被和谐。

    好吧,这是一款本地端登陆CSDN博客的小软件。

    软件有两个窗体,一个是登陆窗体,一个是浏览器窗体,使用了webbrowser组件。

    首先,打开软件:


    在输入框中输入CSDN的用户名和密码,点击登陆将进行自动登陆。



    或许很多人会有疑问,比如这是一个盗号的软件啦等等,其实,这是利用了vb自动填充表格的方法:

    打开登陆网页,查看网页源码:


    黄色部分的地方就是我们需要填充字符串的地方:

    Private Sub Command1_Click()
    Dim vDoc, vTag
    Dim i     As Integer
    Set vDoc = Form2.WebBrowser1.Document
    For i = 0 To vDoc.All.length - 1                 '检测所有标签
    If UCase(vDoc.All(i).tagName) = "INPUT" Then           '找到input标签
    Set vTag = vDoc.All(i)
      If vTag.Type = "text" Then           '看看是不是我们需要的
        If vTag.Name = "username" Then vTag.Value = Text1.Text    '这里是要搜索的内容
       End If
    End If
    Next i
    For i = 0 To vDoc.All.length - 1                 '检测所有标签
    If UCase(vDoc.All(i).tagName) = "INPUT" Then           '找到input标签
    Set vTag = vDoc.All(i)
    If vTag.Type = "password" Then vTag.Value = Text2.Text          '看看是不是我们需要的
           
    If vTag.Type = "checkbox" Then vTag.Value = "false"
    vTag.Click   '点击提交了,一切都OK了


    如果我们选择了记住密码:

    If Check1.Value = 1 Then
    Open "D:MayuSoftCSDNsignINuser.ini
    " For Output As #1
    Print #1, Text1.Text
    Print #1, Text2.Text
    Close #1
    End If

    将会在D:MayuSoftCSDNsignIN目录下生成user.ini文件用来保存密码。

    !所有的信息都会保存在本地磁盘,不会导致密码泄漏的问题。

    窗体2是简易的浏览器,只提供了前进后退的按钮,功能还是少。

    想着可以跳转到本地默认浏览器中打开,由于Cookie和API不熟悉还是无法实现以上的方法。

    登陆成功后,我们可以进行一切在浏览器中能做的事情,写博客,发博文等等,毕竟,窗体2本身就是一个浏览器,webbrowser是由IE提供内核支持的,如果论HTML5,还是普普通通的登陆吧。



    Form1:

    Option Explicit
    Public s As String
    Public a As String
    Public title As String
    Private Sub Command1_Click()
    Dim vDoc, vTag
    Dim i     As Integer
    Set vDoc = Form2.WebBrowser1.Document
    For i = 0 To vDoc.All.length - 1                 '检测所有标签
    If UCase(vDoc.All(i).tagName) = "INPUT" Then           '找到input标签
    Set vTag = vDoc.All(i)
      If vTag.Type = "text" Then           '看看是不是我们需要的
        If vTag.Name = "username" Then vTag.Value = Text1.Text    '这里是要搜索的内容
       End If
    End If
    Next i
    For i = 0 To vDoc.All.length - 1                 '检测所有标签
    If UCase(vDoc.All(i).tagName) = "INPUT" Then           '找到input标签
    Set vTag = vDoc.All(i)
    If vTag.Type = "password" Then vTag.Value = Text2.Text          '看看是不是我们需要的
           
    If vTag.Type = "checkbox" Then vTag.Value = "false"
    vTag.Click   '点击提交了,一切都OK了
    
    End If
    Next i
    If Check1.Value = 1 Then
    Open "D:MayuSoftCSDNsignINuser.ini" For Output As #1
    Print #1, Text1.Text
    Print #1, Text2.Text
    Close #1
    End If
    'Form2.Caption = Text1.Text
    Form2.Show
    Unload Form1
    End Sub
    
    Private Sub Form_Load()
    
    If Dir("D:MayuSoft", vbDirectory) = "" Then '判断文件夹是否存在
      MkDir ("D:MayuSoft") '创建文件夹
      If Dir("D:MayuSoftCSDNsignIN", vbDirectory) = "" Then '判断文件夹是否存在
        MkDir ("D:MayuSoftCSDNsignIN")
      End If
    End If
    Form2.WebBrowser1.Navigate "http://passport.csdn.net/account/login"
    Open "D:MayuSoftCSDNsignINuser.ini" For Append As #1 '如果没有则新建
    Close #1
    Open "D:MayuSoftCSDNsignINuser.ini" For Input As #2
    If LOF(2) = 0 Then
       a = ""
       s = ""
    Else
    Do
      Input #2, a
      Text1.Text = a & vbCrLf
      Input #2, s
      Text2.Text = s & vbCrLf
    Loop Until EOF(2)
    End If
    Close #2
    End Sub
    
    Private Sub Form_Resize()
    Form2.WebBrowser1.Width = Form1.Width - 500
    Form2.WebBrowser1.Height = Form1.Height - 1200
    End Sub
    

    Form2:

    Option Explicit
    
    
    Dim WithEvents Web_V1 As SHDocVwCtl.WebBrowser_V1
    Private Sub Form_Load()
    
    WebBrowser1.Silent = True
        Set Web_V1 = WebBrowser1.Object         '初始化Web_V1对象
        WebBrowser1.Navigate ("http://community.csdn.net/")
        Command1.Enabled = False  '前进按钮
        Command2.Enabled = False  '后退按钮
    End Sub
    Private Sub Form_Resize()
    WebBrowser1.Top = 500
    WebBrowser1.Left = 50
    WebBrowser1.Height = Me.Height - 400
    WebBrowser1.Width = Me.Width - 200
    End Sub
    Private Sub Web_V1_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
    On Error Resume Next
        Processed = True
        WebBrowser1.Navigate URL
    End Sub
    Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
    Text1.Text = WebBrowser1.LocationURL
    On Error Resume Next
        If (Command = CSC_NAVIGATEBACK) Then
            Command2.Enabled = Enable
        End If
        If (Command = CSC_NAVIGATEFORWARD) Then
            Command1.Enabled = Enable
        End If
    
    End Sub
    
    Private Sub Command2_Click()
    On Error Resume Next
        WebBrowser1.GoBack         '后退
    End Sub
    
    Private Sub Command1_Click()
    On Error Resume Next
        WebBrowser1.GoForward      '前进
    End Sub
    
    

    下载

    CSDN自动登陆

    @ Mayuko


  • 相关阅读:
    Git
    Qcon2016上海站PPT
    TeamCity
    在cmd界面,怎么样退出Node.js运行环境
    python 2.x与python3.x的区别
    d3.max()与d3.min()
    d3.svg.line() 曲线构造器
    d3.js 之SVG:矢量化图形绘制
    moment.js 时间格式化库
    directive
  • 原文地址:https://www.cnblogs.com/mayuko/p/4567547.html
Copyright © 2020-2023  润新知