您现在的位置是:首页 > Excel技巧>快递单号查询系统

手机快递单号查询系统-快递单号查询系统

发布于2022-04-150人已围观

此应用是调用网页功能,快速提取数据的一个实例。通过输入快递单号,自动查询快递信息

输入快递单号后,按查询按钮,会显示整个快件从发货到收货的过程,包括时间,地点,途经,操作员等等相关信息。


作者:Excel小子-Office中国

 

Excel快递单号查询操作动画

手机快递单号查询系统

 


  Excel快递单号查询详细VBA代码:               

    

        Sub Main()

            Dim strText As String

            Dim sjs

            Dim i

            Randomize

            sjs = Rnd

            Dim re, m

            Set re = CreateObject("vbscript.regexp")

            

            re.Global = True

            re.Pattern = "ftime"":""([^""]+)"",""context"":""([^""]+)"

            With CreateObject("MSXML2.XMLHTTP") 'CreateObject("WinHttp.WinHttpRequest.5.1")'

                .Open "GET", "http://www.kuaidi100.com/query?type=" & kuaidi & "&postid=" & Cells(1, 5) & "&id=1&valicode=&temp=" & sjs, False

                .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

                .setRequestHeader "Referer", ""

                .Send

                strText = .responsetext

                Set m = re.Execute(strText)

                Range("A:C").ClearContents

                    For Each m In m

                    i = i + 1

                    Cells(i, 1) = m.submatches(0)

                    Cells(i, 3) = m.submatches(1)

                    Next m

                

                Debug.Print strText

            End With

        End Sub

        Sub Main1()

            Dim strText As String

            Dim re, m

            Set re = CreateObject("vbscript.regexp")

            

            re.Global = True

            re.Pattern = "[{""comCode"":""([^""]+)"

            

            With CreateObject("MSXML2.XMLHTTP") 'CreateObject("WinHttp.WinHttpRequest.5.1")'

                .Open "POST", "http://www.kuaidi100.com/autonumber/autoComNum?text=" & Cells(1, 5), False

                .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

                .setRequestHeader "Referer", ""

                .Send

                strText = .responsetext

                Set m = re.Execute(strText)

                

                kuaidi = m(0).submatches(0)

                Debug.Print kuaidi

                Cells(1, 4) = Sheets(3).Range("A:A").Find(kuaidi).Offset(0, 1)

            End With

            Main

        End Sub


点击加入群:OFFICE3658 结识Excel大神
学好Excel,效率成倍提高,薪水稳步增长,职位快速提升
每天一个源创技巧,如觉得有用,请点上面 关注。更重要手机转发分享


如喜欢此技巧,手机右上角点开,分享到QQ空间,方便自己以后看


相关文章

文章评论

表情

共0条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

标签云

站长特荐