domain .tw idv.tw .com.tw
你正在閱覽 :: 繁體中文:: 學習 ASP SQL VB HTML code

學習 .ASP SQL HTML XML CSS JAVA Perl code study
English Chinese_Traditional Chinese_Simplified

你正在閱覽 :: 繁體中文 Chinese_Traditional

學習.主題:
首頁
ASP
. Active-Server-Flash
. Array
. Cache
. Connection
. Count
. Counter
. Distinct
. Email
. File
. Folder
. Function
. GetSQLserver
. Header
. mySQL
. Record
. Recordset
. Request
. Response
. Server
. server-createobject
»AspHTTP-Conn
»Microsoft-XMLDOM
»Microsoft-XMLHTTP
»Microsoft-XMLHTTP-header
»MSXML2-ServerXMLHTTP
»MSXML2.ServerXMLHTTP_2
. ServerVariables
. Session
. Special-Symbols
. String
. Sub
. Time
CSS
Ecommerce
HTML
InternetProtocol
JAVA
Microsoft
php
Robots
SearchEngine
SQL
SQLserver
VBscript
XML

SiteMap

3w....學習.教學 > ASP > server-createobject » asphttp-conn

3w learning

server-createobject >
asphttp-conn

Title:

Set HttpObj = Server.CreateObject("AspHTTP.Conn")


獲取網頁資料
Description:

AspHTTP.Conn can read websites data ----------- note --------- AspHTTP.com may not read https://


獲取某網頁(自己或他人的網頁)資料

Custom Content-Type headers for POST
自动转向
支持多种登陆环境
将远程文件转换成二进制流文件
允许客户端HTTP请求。
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="____"> 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
支援代理設置
用戶端環境判斷
..
...
...

[ 7/29/2010 ]

www learning school add more scripts and tips memo
You are at >>3WT.EZER.COM >> 3WT.EZER.COM/ASP/SERVER-CREATEOBJECT/ASPHTTP-CONN.ASP>>ASP
Helpful link:: SEO web tools :: Live PR | SERP checker Google SERP pageranking checker
back to top Ezer code adding :: Questions ;email