property HTTP.GET (URL as String) as Variant
Retrieves the URL to a string or to a safe array of bytes.

 TypeDescription 
   URL as String A string expression that indicates the HTTP URL to retrieve. The URL parameter may start with http:// or without. You can specify the web server's port by calling something like: http://www.yourserver.com:8080/index.htm, where, the 8080 is the port to be used. By default, the control uses the port 80.  
   Variant A string expression or a safe array of bytes that indicates the body of the message, if the GET operation was ok  
Use the GET method to retrieve pages or documents from the web. The GET method waits until the full document is retrieved.  Use the Timeout property to specify the amount of time (in seconds) the control will wait for the server response. Use the InField property to add additional fields to the GET request. The InField property has effect only before calling the GET method. The OutField property retrieves the header fields after GET method was performed. The OutField property has effect only after GET method was invoked. The GEM method retrieves a string if the web content is text and if it is not encoded, else a safe array of bytes is retrieved. Use the GETImage property to get a Picture object giving its URL.

The following VB sample displays the http://www.exontrol.com web page, in HTML format ( before running the following code, you need to add the exHTTP library to the project's references ):

Dim h As New EXHTTPLib.HTTP
Debug.Print h.GET("http://www.exontrol.com")

The following VB sample gets the http://www.exontrol.com/images/cart.gif picture/document to a safe array:

Dim h As New EXHTTPLib.HTTP
Dim v As Variant, i
v = h.GET("http://www.exontrol.com/images/cart.gif")
For Each i In v
    Debug.Print Hex(i)
Next

The following VB.NET sample displays the http://www.exontrol.com web page ( before running the following code, you need to add the exHTTP library to the project's references ):

Dim n As New EXHTTPLib.HTTP
Debug.WriteLine(n.GET("http://www.exontrol.com").ToString())

The following C++ sample displays the http://www.exontrol.com web page:

#include <atlbase.h>
#import "c:\winnt\system32\ExHTTP.dll"
static COleVariant GET( LPCTSTR szURL, HRESULT* phtError = NULL )
{
	COleVariant vtRequest;
	IUnknown* punkHTTP = NULL;
	OleInitialize( NULL );
	if ( SUCCEEDED( CoCreateInstance( __uuidof( EXHTTPLib::HTTP ), NULL, CLSCTX_ALL, IID_IUnknown, (LPVOID*)&punkHTTP ) ) )
	{
		if ( EXHTTPLib::IHTTPPtr spHTTP( punkHTTP ) )
		{
			USES_CONVERSION;
			HRESULT htError = spHTTP->get_GET( T2OLE(szURL), &vtRequest );
			if ( phtError )
				*phtError = htError;
		}
		punkHTTP->Release();
	}
	OleUninitialize();
	return vtRequest;
}

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}

 


Send comments on this topic.
1999-2015 Exontrol.COM, Software. All rights reserved.