Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Retrieve an HTML Page from Within Your (ASP-)Scripts Without Any Components

0.00/5 (No votes)
28 Aug 2001 1  
Tiny little Perl library to retrieve an arbitrary URL as a string

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here