zoukankan      html  css  js  c++  java
  • 网抓实例:自动修正系统日期和时间

    电脑系统日期和时间,用户可以自己修改。下面的工具可以自动获取标准的北京日期和时间,并修正系统时间。

    代码:

    'By 刘永富,QQ群:61840693
    Public IE As InternetExplorer
    Sub GetDateTime()
        On Error GoTo Err1:
        Dim span_date As MSHTML.HTMLSpanElement
        Dim span_time As MSHTML.HTMLSpanElement
        Dim Sdate As String, Stime As String
        Set IE = New InternetExplorer
        With IE
            .Silent = True
            .Visible = False
            .navigate "https://www.baidu.com/s?wd=%E5%8C%97%E4%BA%AC%E6%97%B6%E9%97%B4"
            While .readyState <> READYSTATE_COMPLETE
                DoEvents
            Wend
            Do
                Set span_date = .document.getElementsByClassName("op-beijingtime-date").Item(0)
                DoEvents
                If span_date Is Nothing = False Then
                    If IsDate(span_date.innerText) Then Exit Do
                End If
            Loop
            Sdate = Trim(span_date.innerText)
            Set span_time = .document.getElementsByClassName("op-beijingtime-time").Item(0)
            Stime = Trim(span_time.innerText)
            Date = CDate(Sdate)
            Time = CDate(Left(Stime, 5) & ":" & Right(Stime, 2))
            .Quit
        End With
        Exit Sub
    Err1:
        MsgBox Err.Description
    End Sub

    附件下载:

    下载地址

  • 相关阅读:
    wenbao与分治
    wenbao与贪心
    wenbao与高精度
    wenbao与FFT
    wenbao与卡特兰数
    wenbao与类
    wenbao与取整函数
    wenbao与字符串转化
    wenbao与scanf
    wenbao与数字与字符串
  • 原文地址:https://www.cnblogs.com/ryueifu-VBA/p/9215309.html
Copyright © 2011-2022 走看看