文章作者 : linkfoxo [ webmaster@cfwindow.com ] Web URL : http://www.cfwindow.com
上载日期 : 2000-12-20
Cfhttp用发一例
以下代码演示如何从网络上取的网页的内容, 以及如何获取以下信息:
获得网页的MIME类型
获得: header responses (responseHeader)
<CFHTTP
URL = "http://www.cftipsplus.com"
resolveurl = 1
throwonerror = Yes
>
</CFHTTP>
<CFOUTPUT>
#cfhttp.filecontent#<BR>
<BR>
<H3><B>The mime-type:</B></H3><BR>
#cfhttp.mimetype#<BR>
<H3><B>The Status Code:</B></H3><BR>
#cfhttp.statuscode#<BR>
<H3><B>The Raw Header:</B></H3><BR>
#cfhttp.header#<BR>
</CFOUTPUT>
<H3><B>Output the Response Headers:</B></H3><BR>
<HR>
<CFLOOP collection=#CFHTTP.RESPONSEHEADER# item="httpHeader">
<CFSET value = CFHTTP.RESPONSEHEADER[httpHeader]>
<CFIF IsSimpleValue(value)>
<CFOUTPUT>
#httpHeader# : #value#<BR>
</CFOUTPUT>
<CFELSE>
<CFLOOP index="counter" from=1 to=#ArrayLen(value)#>
<CFOUTPUT>
#httpHeader# : #value[counter]#<BR>
</CFOUTPUT>
</CFLOOP>
</CFIF>
</CFLOOP>
|