Gossamer Forum
Home : General : Perl Programming :

How to insert a page in another page...

Quote Reply
How to insert a page in another page...
I'd like to insert a complete external page inside my a table of my my home page.
The size should fit but I don't know if I need a cgi program or an applet jav to do that...
Any idea?
Thanks
Cristina

Quote Reply
Re: How to insert a page in another page... In reply to
If the "external" page is in your web site, then you can simply use Server Side Include (SSI).

Like the following:

Code:

!--#include virtual="/file.html"--


Put < before the ! and > after the second --.

This will include the EXTERNAL web page in your home page.

Regards,

Eliot Lee

Quote Reply
Re: How to insert a page in another page... In reply to
Dearest,
thanks a lot BUT I was interesting in inserting a page that IS NOT on my server but somewhere else.
Is there a possible way to it?
Thanks
Cristina

Quote Reply
Re: How to insert a page in another page... In reply to
LWP!

Don't know what it is? Then search http://www.perl.com!

Regards,

Eliot

Quote Reply
Re: How to insert a page in another page... In reply to
I'll check with perl.com!
Thanks
Cristina

Quote Reply
Re: How to insert a page in another page... In reply to
As far as i understand u r interested in retrieving content for other website. If thats the case than check out
http://cgi.resourceindex.com/Programs_and_Scripts/Perl/Content_Retrieval/
Regs
JackofNone

Quote Reply
Re: How to insert a page in another page... In reply to
Jack,
I've already checked with resourceindex.com but there i snothing that really helps me as I need to insert datas from an existing .html page from another server inside one my web pages...
Thanks
Cristina

Quote Reply
Re: How to insert a page in another page... In reply to
I don't know if this is exactly what you are looking for and it may not be the best way but, you can do this:

<IFRAME src="http://www.the site you want to include/file.htm" height="200" width="200"></IFRAME>

Quote Reply
Re: How to insert a page in another page... In reply to
Good suggestion...however...<IFRAME> is not interoperable between web browsers.

Regards,

Eliot Lee

Quote Reply
Re: How to insert a page in another page... In reply to
use LWP::Simple;

my $external_page = get('http://www.whatever.com/page.html');

now just print your variable where you want it and the entire page contents you retrieved will be placed there

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: How to insert a page in another page... In reply to
You could have both IFRAME (for MSIE) and ILAYER (for NN) and the browser should just skip over the unrecognized tag. However, with ILAYER the page being imported must only contian BODY elements.

To do it with LWP, isn't just like two lines?
Code:
use LWP::SIMPLE;
print get('http://www.someothersite.com/something.html');
--Drew
Quote Reply
Re: How to insert a page in another page... In reply to
Mark beat me Frown.

--Drew
Quote Reply
Re: How to insert a page in another page... In reply to
Hi Mark & Junko,
I have created a .cgi with the following content in it.

#!/usr/bin/perl
use LWP::SIMPLE;
print get('http://www.myserver.com/mypage.php3');

When i directly excess this cgi file through the browser it gives an "500 Internal server error" but when i access through telnet it gets the page. Actually i want to include this external page into my homepage through SSI.

Please help me.
Thanks in Advance

Regs
JackofNone

P.S. I m doing this because the server on which my website resides does not supports php3 so i have purchase a php hosting and i have that .php3 page on it.


Quote Reply
Re: How to insert a page in another page... In reply to
Before your print get statement, add:
Code:
print "ContentType: text/html\n\n";
--Drew
Quote Reply
Re: How to insert a page in another page... In reply to
This is what I use:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
use LWP::Simple;
print get "http://www.externalservername.com/pagename.html";;

--------
Give it a name such as get.cgi

Then use a ssi call <%
!--#include virtual="/pathto/get.cgi"--%> to pull it up. Be sure to rename the document .shtml or make a change in your server to recognize .html as .shtml pages. Be sure to take out the % in the above ssi call

Trust in your elders, for they hold the key to life...
Quote Reply
Re: How to insert a page in another page... In reply to
Thanks Junko and Kelroy
Its working now
Kilroy thanks for making it real easy
Thanks Again

Regs
JackofNone

Quote Reply
Re: How to insert a page in another page... In reply to
how can i include the contents in the perl file.

this case i would like to get an external subroutine and print it into the script.

ideas?

Quote Reply
Re: How to insert a page in another page... In reply to
Better thing to do is create a module file and then put it in your common Perl lib directory, then call that module file as you would with another Perl lib module file.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: How to insert a page in another page... In reply to
just want to protect the program from being copied. Can I get the library on a remote sever (mine)?

Quote Reply
Re: How to insert a page in another page... In reply to
It should be LWP::Simple, not LWP::SIMPLE.

LWP::Simple also has a very useful printget() function, which accomplishes the same thing as print get(), but is more efficient - especially with large pages - and prints the page as it retrieves it, so you are streaming the page to the browser. One advantage is that if the server you are getting the page from is slow, you'll be streaming to the browser and (in theory) keeping the browser from timing out.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: How to insert a page in another page... In reply to
If it is your own server what is the point of going to the effort of using the perl module on the other server - just means you have to write more code?......Just upload a copy to your other server.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: How to insert a page in another page... In reply to
bah

#!/she/bang
use Socket;
my $domain = "something.com";
my $port = "80";
my $file = "/path/to/file/or/full/url.html";

my $sockaddr = sockaddr_in $port, inet_aton $domain or die "Bad hostname\n";
socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad socket\n";
connect SOCK, $sockaddr or die "Bad connection\n";
select((select(SOCK), $| = 1)[0]);

print SOCK "GET $file HTTP/1.1\n";
#uhh.. this is how i get rid of headers.. just for reference..
#while (<SOCK>) { /^Content/ and last; }
my $source;
while (<SOCK>) { print; }

close SOCK;




no LWP! socket comes with the perl package.. so you don't need to install anything to use this

Jerry Su
http://www.jsu07.com