ASPHTTP use example

zhaozj2021-02-16  126

Simple instance:

Use this component very simple

1. Create an object

2. Set some properties

3. Call the getURL method

Below is the sample code for VBScript using asphttp

Set httpobj = server.createObject ("asphttp.conn")

Httpobj.url = "http://www.myfinancialpage.com/qrtresults.html"

Strresult = httpobj.geturl

The variable Strresult now contains a string from http://www.myfinancialpage.com/qrtresults.html

Get obtained document results

Example: Get a GIF file

<%

Rem this demo pulls a gif image from www.microsoft.com

Server.scripttimeout = 240

Set httpobj = server.createObject ("asphttp.conn")

Httpobj.url = "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"

Httpobj.followRedirects = false

Httpobj.requestmethod = "get"

Httpobj.useragent = "Mozilla / 2.0 (Compatible; Msie 3.0b; Windows NT)"

Httpobj.savefileto = "c: /write.gif"

Httpobj.geturl

Response.write "


headers receivers
" & httpobj.headers & ""

%>

Example: Handling and displaying the HREF included in the URL

<%

Server.scripttimeout = 240

Set httpobj = server.createObject ("asphttp.conn")

Httpobj.url = "http://www.genusa.com/asp/tools.html"

Httpobj.requestmethod = "get"

Httpobj.useragent = "Mozilla / 2.0 (Compatible; Msie 3.0b; Windows NT)"

Strresult = httpobj.geturl

Response.write "

a href list "

VarhrefaRray = httpobj.gethrefs

INTHREFARRAYLIMIT = Ubound (Varhrefarray) -1

For i = 0 to inthrefarrayLimit

Response.write Varhrefarray (i) & "& vbrlf

NEXT

%>

转载请注明原文地址:https://www.9cbs.com/read-7817.html

New Post(0)