Login   Register  
PHP Classes
elePHPant
Icontem

File: show_news.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Carter Comunale  >  news_parser_4  >  show_news.php  >  Download  
File: show_news.php
Role: ???
Content type: text/plain
Description: This is an example of how the moreover.com news can be parsed
Class: news_parser_4
Author: By
Last change:
Date: 2001-07-04 02:21
Size: 1,612 bytes
 

Contents

Class file image Download
<!-- this is an example of how the news_parser_4.php  can be used. -->
<!-- try it. you might like it. -->

<? include ("news_parser_4.php"); ?>
<html>
<title>Moreover news parse example</title>
<body bgcolor="white">

<!-- search form -->
<form name="moreover_search">

Enter in some key words to search moreover.com<br>
<input type="text" name="search_str" value="<? echo $search_str; ?>">
<input type="hidden" name="action" value="search">
<input type="submit" name="search" value="search">
</form>

<?
// ok run our search
if ($action=="search") {

         // create a news parser
        $xml_news_parser = new news_xml_parser("http://p.moreover.com/cgi-local/page?&k=". urlencode($search_str)."&o=xml");
        // uh, tell it to parse
        $xml_news_parser->parse();
        //free it up
        $xml_news_parser->free_parser();

        //ok now, just deal with the display
        echo "<br><b>".count($xml_news_parser->news_objects)." results for  $search_str</b><br clear=\"all\">\n";
        echo "<table border=1 cellpadding=5 cellspacing=0>\n";

        if (count($xml_news_parser->news_objects)>1){
                foreach ($xml_news_parser->news_objects as $article) {

                        echo "<tr><td><a href=\"".$article->url."\">".$article->harvest_time."<br>".$article->headline_text."&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"".$article->document_url."\">[".$article->source."]</a>\n</td></tr>";

                }
        }
        else {
                echo "<tr><td>No articles found</td></tr>";
        }
}

?>
</table>
</body>
</html>