[Visual Basic] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
Public Function GetMobileLocation(pohoenumber As String ) Dim Url As String Url = "http://cx.shouji.360.cn/phonearea.php?number=" + pohoenumber If pohoenumber <> "" Then Dim xml_http As Object Set xml_http = CreateObject( "Microsoft.XMLHTTP" ) xml_http.Open "get" , Url, True xml_http.sEnd Do Until xml_http.ReadyState = 4 DoEvents Loop Dim bodyData bodyData = xml_http.responseText Dim lastData lastData = Replace(bodyData, "data" , "objectdata" ) Set JSON = CreateObject( "MSScriptControl.ScriptControl" ): JSON.Language = "JScript" Set Obj = JSON.eval( "eval(" & lastData & ")" ) GetMobileLocation = Array(Obj.objectdata.province, Obj.objectdata.sp) ' GetMobileLocation = Obj.objectdata.province Set xml_http = Nothing Else GetMobileLocation = Array( "--" , "--" ) End If End Function |
首先导入函数
使用方法:选中两个单元格=GetMobileLocation(A1),然后ctrl+shift+enter