CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Help with CGI Pleeezzz!

 



Debz
Deleted

Mar 7, 2000, 7:12 AM

Post #1 of 2 (692 views)
Help with CGI Pleeezzz! Can't Post

CGI GRABBER

Please, is there anyone out there that will give me better instructions for this? Or even give me one that will accomplish the same thing this one describes?

I really am desperate to find help. I have been searching for 4 days straight now. I only know a little CGI but I hope to get a lot better soon. I am enrolled for classes at the local Community College for next quarter (but I really need this now!)

I want to give up-to-date local news, stocks,
weather and other info to my viewers. I have found this script but the directions are unclear to me. Can anyone tell me how to configure the settings to go to www.heraldnet.com? If you would please explain
in detail so I can relate your instructions to with more of the same.

THANKS,
Debz

P.S. Disregard the (#) marks, they were from my email. I hope they donŐt make matters worse than they already are!!!

#!/user/bin/perl
#NewsGrabber v. 1.0 # # - SSI Version
# # Written by: Jim Fletcher # # http://jim.fletcher.net # # jim@fletcher.net # #
Use program at your own # # risk, and ask before you
# # use someone's copyrighted # # information on your
site. # # You may not redistribute, # # sell,
use for derivative # # works which you then sell, # #
distribute or assume any # # rights. #
###############################
use English; use CGI; use integer; require
LWP::UserAgent;

Parse Form Inputs
$q = new CGI; #print $q->header; $mytest
=$q->param(mytest);

$ssi = "no"; $ua = new
LWP::UserAgent; $the_cgi = CGI->new;
$domain = "newshub.com/world"; #$domain =
$ENV{'QUERY_STRING'}; # ex.
"script.cgi?yahoo.com"; $begin = "http://";
$data = $begin . $domain; $breakupa = "
; # If this string is in a line, that line
will be printed. $breakupb a0; # If this string is in a line,
that line will be printed. $breakupc 40; # If
this string is in a line, that line will be printed.
$replacea /cgibin; $replaceb http://www.newshub.com/cgibin; $numheads 15; # Number of
headlines you want to be printed Times Three!
$footer Search Results by newshub.com";
$lookup = new HTTP::Request 'GET', "$data";
$response = $ua->request($lookup); @lines =
split (/\n/, $response->content);

if ($ssi eq "no") { print "Content-type:
text/html\n\n"; }

print $mytest;

$i = 0; foreach $line (@lines) { if ($line =~
/$breakupa/ && $i < $numheads) { $line =~
s/$replacea/$replaceb/; print $line; $i += 1; }
elsif ($line =~ /$breakupb/ && $i < $numheads) {
print $line; $i += 1; } elsif ($line =~
/$breakupc/ && $i < $numheads) { print $line; $i += 1; } }
print $footer; exit;
______________________________________

THE READ ME FILE

Website News Grabber V 1.0!
-- Copyright 1999 Jim Fletcher- -
jim@fletcher.net - - http://jim.fletcher.net -
This script is designed to put headlines on your
websites. It has many variables to let you customize
the information. The example grabs headlines and
other information from NewsHub.com.

Understanding the variables: Breakup Values: I
have built in three "Breakup values". When the
script visits the webpage you tell it to, it
will read each line of the webpage. If the line has any of
the "Breakup values", then it will print that
line. By finding sufficiently "unique" Breakup
strings (these are strings that only the lines
you want contain), then only the data you want will
be printed. I built in the possibility of
having three criteria. If you want to add more, feel free by
modifying the script with more "elsif"
statements. If you don't need the 2nd or 3rd criteria, set
them to some totally random string that
couldn't possibly be in the webpage, but DON'T LEAVE
THEM BLANK! Replace Values: If the website has
used relative links & you want to make
these hard links, then follow the example to
see how to change the relative link to a hard link.
Num Heads: This is the total number of
"Headlines" that you want. I set this to the number of
headlines I want, mul



darian
Deleted

Mar 7, 2000, 11:03 PM

Post #2 of 2 (692 views)
Re: Help with CGI Pleeezzz! [In reply to] Can't Post

Debz,
From what I saw in the program you can do it two ways. One is a form that they already have built for you. This way you simply fill in the info required in the fields. The other way is using SSI calls from your page. With SSI calls you need to do something like:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

<!--#exec cgi="http://yoursite.com/cgi-bin/newshub2.pl" --></pre><HR></BLOCKQUOTE>

Add that to your page where you want the news to be. Now go to the newshub2.pl script and change the following to match what you want.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

$ssi = "no";
$domain = "newshub.com/world";
$breakupa = "<li>";
$breakupb = "a0";
$breakupc = "40";
$replacea = "/cgibin";
$replaceb = "http://www.newshub.com/cgibin";
$numheads = "30";</pre><HR></BLOCKQUOTE>

You'll notice that I am only showing you a small part of the script. These are the only things you need to change to make the script work for your site. For the $domain variable you need to find out what directory they are putting their stories that you want to show in. Then put only the part after the http://. You will also need to know how they setup their headlines. For example $breakupa looks for the HTML tag <li>. When it sees the <li> it then takes that line in as a Headline and prints it.

Hope this helps. I did run it on the site you wanted to and could not find any one particular directory that held the headlines so you may have to contact the webmaster of the site and ask them about it.

Stanley

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives