Click here to Skip to main content
15,881,424 members
Articles / Web Development / IIS

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

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
28 Aug 2001CPOL 58.2K   734   6   3
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.

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

or:

PERL
...
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
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.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions

 
QuestionLWP? Pin
Anonymous28-Apr-04 17:15
Anonymous28-Apr-04 17:15 
QuestionEasier way? Pin
30-Jul-01 4:42
suss30-Jul-01 4:42 
AnswerRe: Easier way? Pin
6-Mar-02 19:35
suss6-Mar-02 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.