asp 获取url 返回值 和 对json 返回值的处理

摘要:
1FunctionGetHttpPage(HttpUrl,endoce)2Ifendoce=""Thenendoce="GB2312"3IfIsNull(HttpUrl)=TrueOrLen(HttpUrl)˂18OrHttpUrl="$False$"Then4GetHttpPage="$False$"5ExitFunction6EndIf7DimHttp8SetHttp=server.creat
1 Function GetHttpPage(HttpUrl,endoce)
2 If endoce = "" Then endoce = "GB2312"
3     If IsNull(HttpUrl)=True Or Len(HttpUrl)<18 Or HttpUrl="$False$"Then
4 GetHttpPage="$False$"
5 Exit Function
6 End If
7 Dim Http
8 Set Http=server.createobject("MSXML2.XMLHTTP")
9     Http.open "GET",HttpUrl,False
10 Http.Send()
11 If Http.Readystate<>4 Then
12 Set Http=Nothing 
13 GetHttpPage="$False$"
14 Exit function
15 End if
16 GetHTTPPage=bytesToBSTR(Http.responseBody,endoce)
17 Set Http=Nothing
18     If Err.number<>0 then
19 Err.Clear
20 End If
21 End Function
22 
23 Function BytesToBstr(Body,Cset)
24 Dim Objstream
25 Set Objstream = Server.CreateObject("adodb.stream")
26 objstream.Type = 1
27 objstream.Mode =3
28 objstream.Open
29 objstream.Write body
30 objstream.Position = 0
31 objstream.Type = 2
32 objstream.Charset = Cset
33 BytesToBstr = objstream.ReadText 
34 objstream.Close
35 set objstream = nothing
36 End Function
37 
38 Dim scriptCtrl  
39 Function parseJSON(str)  
40 If Not IsObject(scriptCtrl) Then  
41 Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")  
42 scriptCtrl.Language = "JScript"  
43 scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"  
44 End If  
45 scriptCtrl.ExecuteStatement "result = " & str & ";"  
46 Set parseJSON = scriptCtrl.CodeObject.result  
47 End Function  
48     
49 Dim json  
50 
51     URL = "https://www.sojson.com/api/beian/"&session("domainname")
52 json = GetHttpPage(URL,"UTF-8")
53 Set obj = parseJSON(json)  
54 
55 domain_type =  obj.type
56 Response.Write domain_type
57     
58     Set obj = Nothing 

asp 获取url 返回值 和 对json 返回值的处理

免责声明:文章转载自《asp 获取url 返回值 和 对json 返回值的处理》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇oracle 中生成流水号 方法ThinkPHP部署下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

一些使用JSP 编程技巧(转)

  1. 如何让选中的一行记录高亮显示?http://topic.csdn.net/t/20050105/09/3699823.html2. 如何在下拉列表框里选择一个值后跳出新窗口?http://topic.csdn.net/t/20050107/15/3707444.html3. 如何在JSP中启动execl?http://community.csd...

C# 使用ffmpeg.exe进行音频转换完整demo-asp.net转换代码

C# 使用ffmpeg.exe进行音频转换完整demo-asp.net转换代码   上一篇说了在winform下进行调用cmd.exe执行ffmpeg.exe进行音频转换完整demo.后来我又需要移植这个方式到asp.net中,但是asp.net和winform程序有很多不同。 需要修改WavConvertToAmr的方法,支持asp.net 1、W...

Mysql Select 语句中实现的判断

  select *,if(sva=1,"男","女") as ssva from tableame where id =1 Quote 控制流程函数 CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END...

使用CompletableFuture优化你的代码执行效率

  这篇文章详细讲解java8中CompletableFuture的特性,方法以及实例.   在java8以前,我们使用java的多线程编程,一般是通过Runnable中的run方法来完成,这种方式,有个很明显的缺点,就是,没有返回值,这时候,大家可能会去尝试使用Callable中的call方法,然后用Future返回结果,如下: public stati...

委托和多线程(一)

         定义:委托是一个类型安全的对象,它指向程序中另一个以后会被调用的方法(或多个方法)。通俗的说,委托是一个可以引用方法的对象,当创建一个委托,也就创建一个引用方法的对象,进而就可以调用那个方法,即委托可以调用它所指的方法。 委托的试用步骤: 1、定义委托:权限修饰符   delegate   返回值     委托名 (参数); 2、声明委托...

记录ASP.NET CORE 3 部署过程

    环境为:window server 2008 IIS6.1  net core 3     首先时安装net.core 运行时。地址为:https://dotnet.microsoft.com/download/dotnet-core/3.0   大家找对应的版本进行下载安装。     IIS中创建网站,配置应用程序池.NET FrameWork...