faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Functions : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 16 people (75%) answered Yes
Recently 4 of 7 people (57%) answered Yes


How can I read the contents of a specific web-page (e.g. http://www.google.com) into a string-variable?

Jul 4th, 2001 03:17
Acebone, Esben Maaløe,

The question was really how to read a web-page *using* VBScript or 
JScript. But you can install perl on your webserver and then do like 
UPDATE: Here's how to do it with VB-Script:
------------ ASP PAGE BEGINS -------
sub getHTTP() {
        my ($url,$file,$method) = @_;
        #if the $file parameter is provided 
        #the content of the retrieved file
        #will be saved into the filename in $file
        use LWP::UserAgent;
        $method = 'GET' unless $method;
        my $ua = new LWP::UserAgent;
        my $request = new HTTP::Request($method, $url);
        $response = $ua->request($request, $file);
        return $response->content();
        strHTTP = getHTTP("http://www.acebone.f2s.com")
------------ ASP Page ends ------------
NB! If the URL cannot be found, you won't get an error, just an empty 
string. Perhaps the UserAgent object has an error property you could 
For some reason this doesn't work on my PWS98 server, but it does on an 
IIS4+ server
I recommend ActivePERL -
(BTW - It's really easy to install, and it's free of charge)

© 1999-2004 Synop Pty Ltd