青海龙8国际乐建设、网络推广最好的公司--您身边的龙8国际乐建设专家,马上拿起电话,联系我们:0971-8235355   
青海西宁龙8国际乐建设、龙8国际乐制作公司-西宁威势电子信息服务有限公司
 
西宁威势最新龙8国际乐制做案例展示
Lastest Project
 
当前位置为:首页 >> ASP编程 >> 正文  
龙8国际乐_龙8国际娱乐电脑版_龙8国际娱城手机版

文章来源: 西宁威势电子信息服务有限公司     发布时间:2008-12-15    浏览次数:4965    tags:AspHTTP.Conn

AspHTTP.Conn  
   
           
          AspHTTP组件的属性  
   
          Accept    
          指示什么样的MIME类型可以被请求程序接受  
          例如:  
          HttpObj.Accept   =   "*/*"  
   
          Authorization    
          授权头可以让你获得   需要验证身份的地方的url  
          用户名和口令之间用冒号点开  
          例如:  
          HttpObj.Authorization   =   "jimb:superbmr"  
   
          BinaryData    
          返回来自getURl请求获得的两进制格式的数据,你可以用这个属性取得两进制数据  
          如来自另一个web服务器的图片例如:  
          <%  
          Response.ContentType   =   "image/gif"  
          Set   HTTPObj   =   Server.CreateObject("AspHTTP.Conn")  
          HTTPObj.Url   =   "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"  
          HTTPObj.GetURL  
          Response.BinaryWrite   HTTPObj.BinaryData  
          %>  
   
          ContentType    
          这个属性允许你在POST操作时自定义content-type头  
          例如:  
          ContentType   =   "application/x-www-form-urlencoded"  
   
          Error    
          报告请求中发生的任何错误  
   
          FollowRedirects    
          FollowRedirects告诉组件跟随HTTP   Server的重定向  
          例如:  
          HttpObj.FollowRedirects   =   true  
   
          Headers    
          Headers属性包含了在请求被调用GetURL处理完成之后,来自http请求的回应头  
          例如:  
          Response.Write   HttpObj.Headers  
   
          Port    
          Port属性指示连接http服务器的端口号  
          例如:  
          HttpObj.Port   =   80  
   
          PostData    
          PostData属性应该被设置为你希望post请求POST到web服务器的数据的值  
          例如:  
          HttpObj.PostData   =   "suid=jimb&act=upd"  
   
          Protocol    
          指示请求应该使用的http协议版本号,缺省值是HTTP/1.0  
          例如:  
          HttpObj.Protocol   =   "HTTP/1.1"  
   
          Proxy    
          proxy属性包含proxy   server代理服务器的地址/端口,冒号点开  
          例如:  
          HttpObj.Proxy   =   "address.net:2001"  
   
          ProxyPassword    
          设置需要验证的http代理服务器的http代理密码,现在只支持basic   authentication(基本验证)  
   
          RequestMethod  
          RequestMethod属性指示发给服务器http请求的类型,合法的值是"GET",   "POST"   和   "HEAD".  
          例如:  
          HttpObj.RequestMethod   =   "POST"  
   
          RegisteredUser    
          RegisteredUser属性指示组件授权用户的名字  
          例如:  
          Response.Write   "This   component   is   licensed   to   "   &   HttpObj.RegisteredUser  
   
          Response    
          Response属性包含在收到web服务器过来的请求之后的http   response回应  
   
          SaveFileTo  
          SaveFileTo允许你得到任何类型的文件,自动存到本地盘上。图形/文本/HTML文件均可以。  
          例如:  
          HttpObj.SaveFileTo   =   "c:\images\3rdqrtr.jpg"  
   
          TimeOut    
          timeout属性决定组件等待http   server响应的时间  
          例如:  
          HttpObj.TimeOut   =   45  
   
          URL    
          URL属性设定你希望request请求所操作的url,以http://开头  
          例如:  
          HttpObj.URL   =   "http://www.myfinancial.com/scripts/update3.asp"  
   
          UserAgent  
          UserAgent让组件通过发送一个request的UserAgent头伪装浏览器  
          例如:  
          HttpObj.UserAgent   =   "Mozilla   Compatible   (MS   IE   3.01   WinNT)"  
   
          Version    
          指示AspHTTP组件的版本  
          例如:  
          Response.Write   "The   component   version   is   "   &   HttpObj.Version  
   
          AspHTTP组件的方法  
   
  方法   参数   返回值   描述    
  GetURL   无   String   返回http请求的响应,这是一个字符串,组件不支持2进制返回值,如Gif/Jpg图像    
  AddExtraHeader             String             无   在请求内增加一个自定义的http头,自定义头可以包括模拟的浏览器头,例如IE的分辨率信息头    
  ClearExtraHeaders     无   无   清除所有AddExtraHeader设置的http头    
  GetHeader     String     String     在GetUrl调用之后,获得自定头的值,如果有多个头,返回第一个。要检索所有的头,请看GetHeaders  
  Example:  
  strCookie   =   HttpObj.GetHeader("Set-Cookie")  
  You   could   then   on   subsequent   calls   return   the   same   cookie   as   follows:  
  if   strCookie   <>   ""   then  
      HttpObj.AddExtraHeader   "Cookie:   "   &   strCookie  
  end   if    
  GetHREFs             无   Variant             字符串数组,在调用GetUrl之后,你可以调用GetHREFs处理html里面的<a   href="">   Tags.  
  GetHREFs返回一个你可以进一步处理或显示的字符串的可变数组  
  请见HREFList.asp(下载包内有)使用这个方法的示例代码,GetHREFs是在aspHTTP版本2.4增加的。    
  URLDecode             strValue     String             解码一个URL编码的字符串    
  URLEncode             strValue     String             将一个字符串编码成一个合法的url值  
  Example:  
  HttpObj.URL   =   HttpObj.URLEncode("http://www.test_xyz.com?avalue=this   is   a   value   with   spaces")    
以下是引用片段:
Example Code:

Example 1 :: to run a site HTTP <% Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.-----.com" HTTPObj.TimeOut = 5 'set the timeout strResult = HTTPObj.GetURL SET HTTPobj = nothing response.write strResult %> Example 2 :: to get the HTML code show <% Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.-----.net" HTTPObj.TimeOut = 5 'set the timeout strResult = HTTPObj.GetURL SET HTTPobj = nothing HTMLstrResult=Server.htmlEncode(strResult) response.write HTMLstrResult %> Example3 and Example4 ------ off html code ---- <% Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.-----.net" HTTPObj.TimeOut = 5 'set the timeout strResult = HTTPObj.GetURL SET HTTPobj = nothing HTMLstrResult=Server.htmlEncode(strResult) 'response.write HTMLstrResult '-----function clearHTMLCode(originCode)---- function clearHTMLCode(originCode) dim reg set reg = new RegExp reg.Pattern = "<[^>]*>" reg.Global = true clearHTMLCode = reg.Replace(originCode, "") end function '-----function Checkin(s)---------- function Checkin(s) s=trim(s) s=replace(s,vbCrlf,"") s=replace(s,chr(9),"") s=replace(s," ","") s=replace(s,"&nbsp;","") Checkin=s end function ' chr(10) may change some code '----Example 3------ response.write clearHTMLCode(strResult)&"<hr>" '----Example 4------ response.write Checkin(clearHTMLCode(strResult)) %> ------ Example 5 list all hrefs: HttpObj.GetHREFs----- <html> <body> <% '---------------HttpObj.GetHREFs-------- Server.ScriptTimeout = 5 Set HttpObj = Server.CreateObject("AspHTTP.Conn") HttpObj.Url = "http://----.com/" HttpObj.RequestMethod = "GET" HttpObj.UserAgent = "Mozilla/2.0 (compatible; MSIE 6.0B; Windows NT)" strResult = HttpObj.GetURL Response.Write "<h2>A HREF List</h2>" varHREFArray = HttpObj.GetHREFs intHREFArrayLimit = UBound(varHREFArray) -1 For I = 0 to intHREFArrayLimit Response.Write I+1&" : "&varHREFArray(I) & "<br>" & VBCrLF Next %> </body> </html> -----Example 6 ::------------ <% ' get image/gif Response.ContentType = "image/gif" Set HTTPObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://----.com/---.gif" HTTPObj.GetURL Response.BinaryWrite HTTPObj.BinaryData %> ------- Example 7 get and save image file <% Server.ScriptTimeout = 240 Set HttpObj = Server.CreateObject("AspHTTP.Conn") HttpObj.Url = "http://www.----.com/---.gif" HttpObj.FollowRedirects = false HttpObj.RequestMethod = "GET" HttpObj.UserAgent = "Mozilla/2.0 (compatible; MSIE 6.01; Windows NT)" HttpObj.SaveFileTo = "D:/myPath/log.gif" HttpObj.GetURL Response.Write "image saved" %> <% ' ---- Example 8 ----get file and save Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.----.com/" 'HTTPObj.PostData = "suid=jimb&pwd=macabre&id=32&val=1.5" HTTPObj.TimeOut = 1800 HTTPObj.Accept = "*/*" HTTPObj.FollowRedirects = true HTTPObj.Port = 80 'HTTPObj.Proxy = "---.net:8080" 'HTTPObj.ProxyPassword = "proxyusername:proxypassword" HttpObj.SaveFileTo = "D:/myPath/newfilename.html" HTTPObj.UserAgent = "Mozilla Compatible (MS IE 3.01 WinNT)" HTTPObj.Protocol = "HTTP/1.1" HTTPObj.Authorization = "USER:pass" HTTPObj.ContentType = "application/x-www-form-urlencoded" HTTPObj.RequestMethod = "POST" 'HTTPObj.GetHREFs 'HTTPObj.RequestMethod = "HEAD" strResult = HTTPObj.GetURL response.write strResult %>


---------- Ezer Tips ----------

反制他人不經瀏覽器或經快捷徑工具列
來獲取網頁資料?
SEs 也已經在2006漸漸開始注意到
並發展?. 反制功能
其實獲取網頁資料就好比網界文機器人
獲取網頁資料?
Ezer Tips:反制功能其實也不難
小心使用JAVA可能會影響HttpObj.GetHREFs
的計算結果
--------------
Example Result:

Example website usage: http://link.ezer.com/tools/backlink_checker.asp


Example 1 :: will see a site image of www.----.com Example 2 :: will print the HTML code of www.----.net Example 3 :: will not list any html code of www.----.net Example 4 :: will not list any html code of www.----.net and do not list replaced item Example 5 :: list all href from HttpObj.Url href includes email and file which form as: <a href="http://wmcgw.net/TipxOfxt/____"> URL </a> Attention:: Java ex: onLoad="scrollIn()" at body tag may affect the href counting result.... Example 6 :: get image/gif Example 7 :: get and save image file Example 8 :: get file and save


GET, HEAD and POST 的方法請求
返回HTTP協定頭
接受被修改過的HTTP頭, 
若無法通過headers status則會產生error
支援代理設置
用戶端環境判斷

评论列表
正在加载评论……
  
评论   
呢  称:
验证码:
若看不清请点击更换!
内  容:
 
 
  在线洽谈咨询:
点击这里,在线洽谈   点击这里,在线洽谈   点击这里,在线洽谈
乘车路线    汇款方式   加盟合作  人才招聘
 
公司地址:青海省西宁市西关大街73号(三二四部队招行所四楼)     青ICP备13000578号-1 公安机关备案号:63010402000123    
QQ:147399120    mail:lostlove000@163.com    电话: 13897410341    邮编:810000
© Copyright( 2008-2009) QhWins.Com All Rights Reserved    版权所有:西宁威势电子信息服务有限公司 未经书面制授权,请勿随意转载!