Attribute VB_Name = "modHtmlSource" Option Explicit ' ' '============================================================================================================= ' ' modHtmlSource Module ' -------------------- ' ' Created By : Kevin Wilson and Chris Smith ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Created On : January 10, 2002 ' Last Update : June 19, 2002 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : Microsoft XML, v2.0 [or better] (MSXML.DLL - This comes with MS Internet Explorer 4.0 or better) ' ' Description : This module makes it easy to make an HTTP request to a specified web page and get back ' result of that request in either HTML or XML format. ' ' See Also : http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/001/013/msdncompositedoc.xml ' http://msdn.microsoft.com/library/en-us/xmlsdk30/htm/xmmscxmlreference.asp ' http://msdn.microsoft.com/library/en-us/xmlsdk/htm/dom_reference_2kdh.asp ' http://msdn.microsoft.com/downloads/topic.asp?URL=/MSDN-FILES/028/000/072/topic.xml ' http://msdn.microsoft.com/nhp/default.asp?contentid=28000438 ' http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/001/439/msdncompositedoc.xml ' http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/001/013/msdncompositedoc.xml ' http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/000/537/msdncompositedoc.xml ' ' Example Use : ' ' Public Sub Main() ' Dim vntSource As Variant ' Dim lngErrNum As Long ' Dim strErrDesc As String ' If HTML_GetSource("http://www.TheVBZone.com", vntSource, , , , , , lngErrNum, strErrDesc) = False Then ' MsgBox "The following error occured:" & Chr(13) & Chr(13) & "Error Number = " & CStr(lngErrNum) & Chr(13) & "Error Description = " & strErrDesc, vbOKOnly + vbExclamation, " ERROR" ' Else ' MsgBox vntSource ' End If ' End Sub ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= '============================================================================================================= ' HTML_GetSource ' ' Purpose: ' -------- ' This function goes to the specified URL, executes the HTML, ASP, XML, XSL, CGI, etc. located at that URL ' and returns back the source code of what would be the result to be displayed in a web browser. This is ' the equivelant of you going to a web site with Internet Explorer or Netscape, letting the page fully load ' then viewing the source behind the return for that URL. ' ' Parameter: Use: ' --------------------------------------------------- ' strURL The URL of the site to download the HTML source code. This must be an absolute URL, such as "http://Myserver/Mypath/Myfile.asp" ' Return_Content If the "blnReturnXML" parameter is FALSE, returns the HTML source code returned from the HTTP request. ' If the "blnReturnXML" parameter is TRUE, returns an "MSXML.DOMDocument" object with the XML returned from the HTTP request. ' strMethod Optional. HTTP method used to open the connection (such as GET, POST, PUT, or PROPFIND) ' vntBody Optional. This parameter is the request body to use to be sent via the HTTP request ' to the server. This can be one of 4 things: A String, an Byte Array, an XML DOM ' object, or an IStream object. ' - String: the response is always encoded as UTF-8. The caller must set a Content-Type header with the appropriate content type and include a charset parameter. ' - Byte Array (SAFEARRAY of UI1): the response is sent as is without additional encoding. The caller must set a Content-Type header with the appropriate content type. ' - XML DOM Object: the response is encoded according to the encoding attribute on the