Introduction

Today I needed to retrieve a HTML document not local to my website
from within an ASP application and display its content. I've written some time ago another
ActiveX component, but I wanted it this time without any components.

Therefore I used PerlScript that comes with ActivePerl
to write two small functions in Perl and use them from within normal (VBScript-)ASP.

Just two functions

The functions are called GetUrlContent(url) and GetUrlBody(url).
Both functions return the content of an arbitrary URL as a string. The first function returns
the whole content, whereas the second function returns only what is inside the <body>
-tags.

The usage of the functions is very easy, just call them with the URL you wisth to retrieve. E.g.

...
Response.Write GetUrlContent("http://www.codeproject.com/")
...

or

...
Response.Write GetUrlBody("http://www.codeproject.com/")
...

Installation

Beside the latest version of ActiveState's ActivePerl,
you need to download and install the libwww-perl
from cpan.org.

Share

About the Author

Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.

Comments and Discussions

The method mentioned in this article involves installing ActivePerl, which to me means you might as well get a COM component.

However why go through the trouble if you are running your web server on IIS 5? You can use the XMLHTTP object that comes with Microsoft XML 3.0. You can also use this on IIS 4 by installing XML 3 (http://www.microsoft.com/xml)