Excel获取手机归属地
媳妇有工作需求做出工具,分享出来
[Visual Basic] 纯文本查看 复制代码 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
使用效果
|