Introduction
Today, I needed to retrieve an 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 wish to retrieve. E.g.
...
Response.Write GetUrlContent("http://www.codeproject.com/")
...
or:
...
Response.Write GetUrlBody("http://www.codeproject.com/")
...
Installation
Besides the latest version of ActiveState's ActivePerl, you need to download and install the libwww-perl from cpan.org.