This looks exactly like what i need, but being a bit of a perl novice I'm still not able to use this advice as I'd like.
I am trying to write a web page that will allow the surfer to enter a url, fetch the page content, then process the content (partially translate it into German**.), and produce a new copy of the now modified page. This would be fine if all the pages the surfer wanted were behind the university firewall were my proto-script lives. Of course, I want them to be able to access the entire web. If anyone could explain why the LWP::UserAgent method below doesn't solve my problem I'd be very grateful.
**It's for intermediate learners of english
Toby
######################################
#!/usr/local/bin/perl
use URI;
use LWP::Simple;
print "Content-type:text/html\n\n";
$ua->proxy('http', 'http://$myproxy:$myport');
my $content = get("http://news.bbc.co.uk");
#Store the output of the web page (html and all) in content
if (defined $content)
{
#$content will contain the html associated with the url mentioned
+above.
print $content;
}
else
{
#If an error occurs then $content will not be defined.
print "Error: Get stuffed";
}
############################################
Edit: Added <code> tags. larsen
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|