Jump to content

soggy

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

soggy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php include 'http://www.anysite.com/credits.php'?> The above code works fine, but is there a way to pull it without listing http://www.anysite.com? The page pulling the file is a couple of directories lower in anysite.com/folder1/folder2/folder3/footer.php and the file it is pulling is in the root folder for that domain Also let me state that the domain name is an addon domain but not a sub domain thanks in advance
  2. [quote author=ted_chou12 link=topic=119903.msg491489#msg491489 date=1167091893] trying placing it before this:            case "PUBDATE":            $this->pubDate .= $data;            break; or anywhere else you feel it should be around, because trial and error is the best way to find the solution. [/quote] not working
  3. [quote author=ted_chou12 link=topic=119903.msg491485#msg491485 date=1167091073] anywhere before you need it, that is before you store it or you echo it [/quote]Im a bit of a newbie can you show me in my example? I really thank you for your help
  4. [quote author=ted_chou12 link=topic=119903.msg491478#msg491478 date=1167089981] $date = explode(" ",$date); echo "$date[2] $date[1], $date[3]"; only work with the exact format you shown [/quote]Where in my php does that go? Thanks a bunch
  5. The format that is displaying is [b]Thu, 14 Dec 2006 17:31:00 GMT[/b] I want it to display the date format as Dec 14, 2006 or close too. My php is below. What needs to be added? Thanks in advance [code]<?php class RSSParser  {     var $title        = "";     var $link          = "";     var $description    = "";     var $pubDate        = "";     var $inside_item    = false;     var $item_count    = 0;     var $all_rss_urls = array(                   );   function startElement( $parser, $name, $attrs='' ){       global $current_tag;       $current_tag = $name;       if( $current_tag == "ITEM" )         $this->inside_item = true;   } // endfunc startElement   function endElement( $parser, $tagName, $attrs='' ){       global $current_tag;       if ( $tagName == "ITEM" ) {           if ($this->item_count < 10) {                   printf( "\t<b><a href='%s' target='_blank'>%s</a></b>\n", trim( $this->link ), htmlspecialchars( trim( $this->title ) ) );                printf( "\t%s<br>\n", htmlspecialchars( trim( $this->pubDate ) ) );                   $this->title = "";               $this->description = "";               $this->link = "";       $this->pubDate = "";               $this->inside_item = false;           }           $this->item_count ++;       }   } // endfunc endElement   function characterData( $parser, $data ){       global $current_tag;       if( $this->inside_item ){         switch($current_tag){             case "TITLE":               $this->title .= $data;               break;             case "DESCRIPTION":               $this->description .= $data;               break;             case "LINK":               $this->link .= $data;               break;             case "PUBDATE":               $this->pubDate .= $data;               break;              default:               break;         } // endswitch       } // end if   } // endfunc characterData   function parse_results( $xml_parser, $rss_parser, $file )  {       xml_set_object( $xml_parser, &$rss_parser );       xml_set_element_handler( $xml_parser, "startElement", "endElement" );       xml_set_character_data_handler( $xml_parser, "characterData" );       $fp = fopen("$file","r") or die( "Error reading XML file, $file" );       while ($data = fread($fp, 4096))  {         // parse the data         xml_parse( $xml_parser, $data, feof($fp) ) or die( sprintf( "XML error: %s at line %d", xml_error_string( xml_get_error_code($xml_parser) ), xml_get_current_line_number( $xml_parser ) ) );       } // endwhile       fclose($fp);       xml_parser_free( $xml_parser );   } // endfunc parse_results   function show_title( $rss_url ){               ?>               <?   } // endfunc show_title   function show_list_box( $rss_url ){             ?>       <?   } // end func show_list_box } // endclass RSSParser global $rss_url; // Set a default feed if( $rss_url == "" )   $rss_url = "http://www.dailycamera.com/feeds/headlines/sports/broncos/";     $xml_parser = xml_parser_create(); $rss_parser = new RSSParser(); $rss_parser->show_title( $rss_url ); $rss_parser->parse_results( $xml_parser, &$rss_parser, $rss_url ); $rss_parser->show_list_box( $rss_url ); ?> [/code]
  6. I am kinda new to php and need this string described to me ([^`]*?) I am trying to get this to load the title and link [code] <?php // Screen scraping your way into RSS // Example script, by Dennis Pallett // http://www.phpit.net/tutorials/screenscrap-rss // Get page $url = "http://titansradio.com"; $data = implode("", file($url)); // Get content items preg_match_all ("/<A HREF\=cgi-bin([^`]*?)\br/", $data, $matches); // Begin feed header ("Content-Type: text/xml; charset=ISO-8859-1"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; ?> <rss version="2.0"   xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:content="http://purl.org/rss/1.0/modules/content/"   xmlns:admin="http://webns.net/mvcb/"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">     <channel>         <title>Titans Radio</title>         <description>The latest news from titansradio.com</description>         <link>http://titansradio.com</link>         <language>en-us</language> <? // Loop through each content item foreach ($matches[0] as $match) {     // First, get title     preg_match ("/>\([^`]*?)<\/a/", $match, $temp);     $title = $temp['1'];     $title = strip_tags($title);     $title = trim($title);     // Second, get url     preg_match ("/blurb_view\.cgi([^`]*?)>\/", $match, $temp);     $url = $temp['1'];     $url = trim($url);     // Third, get text     preg_match ("/<p>([^`]*?)<span class=\"byline\">/", $match, $temp);     $text = $temp['1'];     $text = trim($text);     // Fourth, and finally, get author     preg_match ("/<span class=\"byline\">By ([^`]*?)<\/span>/", $match, $temp);     $author = $temp['1'];     $author = trim($author);     // Echo RSS XML     echo "<item>\n";         echo "\t\t\t<title>" . strip_tags($title) . "</title>\n";         echo "\t\t\t<link>" . strip_tags($url) . "</link>\n";         echo "\t\t\t<description>" . strip_tags($text) . "</description>\n";         echo "\t\t\t<content:encoded><![CDATA[ \n";         echo $text . "\n";         echo " ]]></content:encoded>\n";         echo "\t\t\t<dc:creator>" . strip_tags($author) . "</dc:creator>\n";     echo "\t\t</item>\n"; } ?> </channel> </rss> [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.