Headline grabber help!

  • WBO
  • Born
  • Born
  • WBO
  • Posts: 2

Post 3+ Months Ago

Have been trying to get the below script to work again. The main function is that it grabs headlines from Yahoo and displays them your site.

Any help would be greatly appreciated.

WB0
Code: [ Select ]
#!/usr/bin/perl

$end = $ENV{'QUERY_STRING'};
use LWP::Simple;

$top = qq~
<head>
<meta http-equiv=Cache-Control content=no-cache>
<meta http-equiv=Pragma content=no-cache>
<META http-equiv=PICS-Label content='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" on "1999.07.26T09:49-0800" for "http://dailynews.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://rd.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://fullcoverage.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://news.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://vision.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://search.news.yahoo.com" r (n 0 s 0 v 0 l 0))'>
<base href=http://dailynews.yahoo.com/>
<script language=javascript>
var remote = null;
function rs(n,u,w,h){
remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
if (remote != null) {
if (remote.opener == null)
remote.opener = self;
window.name = 'yahooNewsRoot';
remote.location.href = u;
}
}
</script>
</head>
~;

print "Content-type: text/html\n\n";


#Yahoo Top Stories
if ($end eq "top") {

$html = get("http://dailynews.yahoo.com/");
main();
print "$top$html[0]";
}

#Yahoo Business
elsif ($end eq "bus") {

$html = get("http://dailynews.yahoo.com/h/bs/nm/?u");
business_snapshot();
main2();
print "$top$snap";
print "$html[0]";
}

#Yahoo Entertainment News
elsif ($end eq "ent") {

$html = get("http://dailynews.yahoo.com/h/en/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Technology News
elsif ($end eq "tec") {

$html = get("http://dailynews.yahoo.com/h/tc/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Political News
elsif ($end eq "pol") {

$html = get("http://dailynews.yahoo.com/h/pl/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Sports News
elsif ($end eq "spo") {

$html = get("http://dailynews.yahoo.com/h/sp/ap/?u");
main2();
print "$top$html[0]";
}

#Yahoo World News
elsif ($end eq "wor") {

$html = get("http://dailynews.yahoo.com/h/wl/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Science News
elsif ($end eq "sci") {

$html = get("http://dailynews.yahoo.com/h/sc/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Health News
elsif ($end eq "hea") {

$html = get("http://dailynews.yahoo.com/h/hl/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Oddly Enough
elsif ($end eq "odd") {

$html = get("http://dailynews.yahoo.com/h/od/nm/?u");
main2();
print "$top$html[0]";
}

#Yahoo Crime and Trials
elsif ($end eq "cri") {

$html = get("http://dailynews.yahoo.com/h/cr/ct/?u");
main2();
print "$top$html[0]";
}

#Yahoo Lifestyles
elsif ($end eq "lif") {

$html = get("http://dailynews.yahoo.com/h/lf/nm/?u");
main2();
print "$top$html[0]";
}

else {
print "<font color=red><center><b><h2>Please Check Your SSI Path.<h2></b></center></font>";
}

sub main{
@html = split(/<!-- _JC_ MIDDLE COLUMN -->/,$html);
@html = split(/<!-- _JC_ END MIDDLE COLUMN -->/,$html[1]);
$html[0] =~ s/\">/\" target=\_blank\">/ig;
$html[0] =~ s/bgcolor=dcdcdc/bgcolor=$table_bg/ig;
$html[0] =~ s/window\.location\.replace\(window\.location\)\;//ig;

return $html[0]
}

sub business_snapshot{
@html = split(/<!-- _JC_ MARKET SNAPSHOT -->/,$html);
@html = split(/<!-- _JC_ END MARKET SNAPSHOT -->/,$html[2]);
$html[0] =~ s/bgcolor=\"#ccccff\"/bgcolor=$table_bg/ig;
$snap = $html[0];
return $snap
}

sub main2{
@html = split(/<!-- _JC_ STORIES -->/,$html);
@html = split(/<!-- _JC_ END STORIES -->/,$html[1]);
$html[0] =~ s/.html>/.html target=\_blank>/ig;
$html[0] =~ s/<img src=..*>//ig;
return $html[0]
}
  1. #!/usr/bin/perl
  2. $end = $ENV{'QUERY_STRING'};
  3. use LWP::Simple;
  4. $top = qq~
  5. <head>
  6. <meta http-equiv=Cache-Control content=no-cache>
  7. <meta http-equiv=Pragma content=no-cache>
  8. <META http-equiv=PICS-Label content='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" on "1999.07.26T09:49-0800" for "http://dailynews.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://rd.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://fullcoverage.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://news.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://vision.yahoo.com" r (n 0 s 0 v 0 l 0) "http://www.rsac.org/ratingsv01.html" l gen true for "http://search.news.yahoo.com" r (n 0 s 0 v 0 l 0))'>
  9. <base href=http://dailynews.yahoo.com/>
  10. <script language=javascript>
  11. var remote = null;
  12. function rs(n,u,w,h){
  13. remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  14. if (remote != null) {
  15. if (remote.opener == null)
  16. remote.opener = self;
  17. window.name = 'yahooNewsRoot';
  18. remote.location.href = u;
  19. }
  20. }
  21. </script>
  22. </head>
  23. ~;
  24. print "Content-type: text/html\n\n";
  25. #Yahoo Top Stories
  26. if ($end eq "top") {
  27. $html = get("http://dailynews.yahoo.com/");
  28. main();
  29. print "$top$html[0]";
  30. }
  31. #Yahoo Business
  32. elsif ($end eq "bus") {
  33. $html = get("http://dailynews.yahoo.com/h/bs/nm/?u");
  34. business_snapshot();
  35. main2();
  36. print "$top$snap";
  37. print "$html[0]";
  38. }
  39. #Yahoo Entertainment News
  40. elsif ($end eq "ent") {
  41. $html = get("http://dailynews.yahoo.com/h/en/nm/?u");
  42. main2();
  43. print "$top$html[0]";
  44. }
  45. #Yahoo Technology News
  46. elsif ($end eq "tec") {
  47. $html = get("http://dailynews.yahoo.com/h/tc/nm/?u");
  48. main2();
  49. print "$top$html[0]";
  50. }
  51. #Yahoo Political News
  52. elsif ($end eq "pol") {
  53. $html = get("http://dailynews.yahoo.com/h/pl/nm/?u");
  54. main2();
  55. print "$top$html[0]";
  56. }
  57. #Yahoo Sports News
  58. elsif ($end eq "spo") {
  59. $html = get("http://dailynews.yahoo.com/h/sp/ap/?u");
  60. main2();
  61. print "$top$html[0]";
  62. }
  63. #Yahoo World News
  64. elsif ($end eq "wor") {
  65. $html = get("http://dailynews.yahoo.com/h/wl/nm/?u");
  66. main2();
  67. print "$top$html[0]";
  68. }
  69. #Yahoo Science News
  70. elsif ($end eq "sci") {
  71. $html = get("http://dailynews.yahoo.com/h/sc/nm/?u");
  72. main2();
  73. print "$top$html[0]";
  74. }
  75. #Yahoo Health News
  76. elsif ($end eq "hea") {
  77. $html = get("http://dailynews.yahoo.com/h/hl/nm/?u");
  78. main2();
  79. print "$top$html[0]";
  80. }
  81. #Yahoo Oddly Enough
  82. elsif ($end eq "odd") {
  83. $html = get("http://dailynews.yahoo.com/h/od/nm/?u");
  84. main2();
  85. print "$top$html[0]";
  86. }
  87. #Yahoo Crime and Trials
  88. elsif ($end eq "cri") {
  89. $html = get("http://dailynews.yahoo.com/h/cr/ct/?u");
  90. main2();
  91. print "$top$html[0]";
  92. }
  93. #Yahoo Lifestyles
  94. elsif ($end eq "lif") {
  95. $html = get("http://dailynews.yahoo.com/h/lf/nm/?u");
  96. main2();
  97. print "$top$html[0]";
  98. }
  99. else {
  100. print "<font color=red><center><b><h2>Please Check Your SSI Path.<h2></b></center></font>";
  101. }
  102. sub main{
  103. @html = split(/<!-- _JC_ MIDDLE COLUMN -->/,$html);
  104. @html = split(/<!-- _JC_ END MIDDLE COLUMN -->/,$html[1]);
  105. $html[0] =~ s/\">/\" target=\_blank\">/ig;
  106. $html[0] =~ s/bgcolor=dcdcdc/bgcolor=$table_bg/ig;
  107. $html[0] =~ s/window\.location\.replace\(window\.location\)\;//ig;
  108. return $html[0]
  109. }
  110. sub business_snapshot{
  111. @html = split(/<!-- _JC_ MARKET SNAPSHOT -->/,$html);
  112. @html = split(/<!-- _JC_ END MARKET SNAPSHOT -->/,$html[2]);
  113. $html[0] =~ s/bgcolor=\"#ccccff\"/bgcolor=$table_bg/ig;
  114. $snap = $html[0];
  115. return $snap
  116. }
  117. sub main2{
  118. @html = split(/<!-- _JC_ STORIES -->/,$html);
  119. @html = split(/<!-- _JC_ END STORIES -->/,$html[1]);
  120. $html[0] =~ s/.html>/.html target=\_blank>/ig;
  121. $html[0] =~ s/<img src=..*>//ig;
  122. return $html[0]
  123. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

and what IS the problem?
  • WBO
  • Born
  • Born
  • WBO
  • Posts: 2

Post 3+ Months Ago

b_heyer wrote:
and what IS the problem?


The script worked great, but no longer grabs headlines.

It returns just the head and nothing else (a blank screen).

Any advice to get this working again would be appreciated.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I bet the reason it does not work is because its no longer dailynews.yahoo.com, that url redirects to something like this now:

http://story.news.yahoo.com/news?tmpl=index&cid=579

so I think you need to adjust the urls it goes to so it does not redirect, and that might solve your problem. If that doesn't work then the format of the pages might have changed enough that your script doesn't know how to parse the page anymore, meaning much of your script might have to be rewritten. Your script is not that big though, so if you know PERL it should not be too hard. If you do not know PERL I recommend you find the place you got the script and see if they have an update.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 123 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.