Option Explicit
Dim XmlHttp As Object
Dim RegExp As Object
Dim WebCode As String
Dim PostData As StringPrivate Sub Command1_Click()
    If Text1.Text = "" Or Len(Text1.Text) < 7 Then MsgBox "请输入手机号,最少7位数!": Exit Sub
    Set XmlHttp = CreateObject("Microsoft.XMLHTTP")
    Set RegExp = CreateObject("VBscript.RegExp")
    PostData = "number=" & Text1.Text
    XmlHttp.Open "POST", "http://cx.shouji.360.cn/hao", False
    XmlHttp.setRequestHeader "Referer", "http://cx.shouji.360.cn/hao"
    XmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    XmlHttp.setRequestHeader "Content-Length", Len(Text1.Text)
    XmlHttp.send (PostData)
    WebCode = XmlHttp.responseText
    RegExp.Pattern = "city" + Chr(34) + ">(.*)</div></td>[\s\S]*?" & "type" + Chr(34) + ">(.*)</div></td>"
    Label1.Caption = RegExp.Execute(WebCode)(0).SubMatches(0) & RegExp.Execute(WebCode)(0).SubMatches(1)
    Set XmlHttp = Nothing
    Set RegExp = Nothing
End SubPrivate Sub Text1_Change()
If Check1.Value = 1 Then
If Len(Text1.Text) = 7 Then Command1.Value = True
If Len(Text1.Text) < 7 Then Label1.Caption = ""
End If
End Sub

解决方案 »

  1.   

    访问不了外网,你的WebCode内容是什么?贴一下
      

  2.   

    中文显示不正常
    post里要提交编码或压缩方式
      

  3.   

    原来一直用的好好的,昨天360查询归属地网站http://cx.shouji.360.cn/hao升级了可能变了里面的源码。好心人给改改。 谢谢!
      

  4.   

    再抓包,获取正确的post包头信息。
      

  5.   

    WebCode =StrConv(.ResponseBody, vbUnicode)
    改成这样试一试!