Created
August 29, 2012 04:32
-
-
Save axpence/3506863 to your computer and use it in GitHub Desktop.
for stack overflow, multiple_feeds.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
$feed = "http://feeds.feedburner.com/DrudgeReportFeed"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; | |
//echo"<div class ='masonry_item' style='background: #FFFFFF;'><a href='". $link ."'>" . "DRU: " . $pubDate . "<br />" . $title . "</a><!--" . $description . "--></div> <br /> "; | |
echo " | |
<div class='tiled'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>DRU: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
*/ | |
$feed = "http://feeds.reuters.com/reuters/topNews"; | |
$xml = simplexml_load_file($feed); | |
$counter = 1000; | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
$image = $YODEL->image; | |
$counter++; | |
echo "<div class='yo'> | |
<div id='article" . $counter . "' class='modal hide fade in bigModal' style='display: none;'> | |
<div class='modal-header'> | |
<a class='close' data-dismiss='modal'>×</a> | |
<h3>" . $title . "</h3> | |
</div> | |
<div class='modal-body'> | |
<h4>" . $pubDate . "</h4> | |
<p> " . $pubDate . "</p> | |
<!-- <iframe class='full-iframe' src='" . $link . "'></iframe> --> | |
<iframe class='full-iframe' id='myiFrame" . $counter . "' src=''></iframe>"; | |
echo"</div> | |
<div class='modal-footer'> | |
<a href='" . $link . "' class='btn btn-success'>Go To Site</a> | |
<a href='#' class='btn' data-dismiss='modal'>Close</a> | |
</div> | |
</div> | |
</div><!--END YO -->"; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5 style='padding-top: 2px;'>REU: " . $pubDate . "</h5> | |
<p> "; | |
include_once('webcrawler/simple_html_dom.php'); | |
$target_url = $link; | |
$html = new simple_html_dom(); | |
$html->load_file($target_url); | |
//START JUST GETTING THE DIV!: | |
$ret = $html->find('div[id=articleImage]'); | |
if($ret){ | |
foreach($ret as $articleImage){ | |
//echo $articleImage ."<hr>"; | |
echo "<div class='thumbnail'>"; | |
echo $articleImage->childNodes(0); | |
echo "</div>"; | |
} | |
} | |
//if doesnt have image above | |
if(!$ret){ | |
$ret = $html->find('div[id=displayFrame]'); | |
foreach($ret as $articleImage){ | |
echo "<div class='thumbnail'>"; | |
echo $articleImage; | |
echo "</div>"; | |
} | |
} | |
echo $description ; | |
echo "</p>"; | |
echo "<p> | |
<!-- <a class='btn btn-primary' href='" . $link . "'> Source </a> --> | |
<a data-toggle='modal' id='article_button" . $counter . "' href='#article" . $counter. "' class='btn btn-primary'><i class='icon-eye-open'></i>View</a> | |
<a class='btn' href='#'><i class='icon-thumbs-up'></i></a> | |
</p> | |
</div> | |
<!--START iframe LOAD STUFF --> | |
<script> | |
$('#article_button" . $counter . "').click(function(){ | |
var iframe = $('#myiFrame" . $counter ."'); | |
iframe.attr('src', '" . $link ."'); | |
}); | |
</script> | |
<!--END iframe LOAD STUFF -->"; | |
echo "</div> <!--END BOX--> | |
<br>"; | |
} | |
echo"<div class='box'><div class ='newz_caption' style='background: #FFFFFF;'><br><br><br><br> <h1>START NON-PARSED FEEDS</h1></div></div>"; | |
echo"<div class='box'><div class ='newz_caption' style='background: #FFFFFF;'><br><br><br><br> <h1>START NON-PARSED FEEDS</h1></div></div>"; | |
echo"<div class='box'><div class ='newz_caption' style='background: #FFFFFF;'><br><br><br><br> <h1>START NON-PARSED FEEDS</h1></div></div>"; | |
echo"<div class='box'><div class ='newz_caption' style='background: #FFFFFF;'><br><br><br><br> <h1>START NON-PARSED FEEDS</h1></div></div>"; | |
$feed = "http://rss.cnn.com/rss/cnn_topstories.rss"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
$image = $YODEL->image; | |
//echo"<div class ='masonry_item' style='background: #FFFFFF;'><a href='". $link ."'>" . "RUT: " . $pubDate . "<br />" . $title . "</a> <!--" . $description . "--></div> <br>"; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>CNN: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
$feed = "http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=breakingnews"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
$image = $YODEL->image; | |
//echo"<div class ='masonry_item' style='background: #FFFFFF;'><a href='". $link ."'>" . "RUT: " . $pubDate . "<br />" . $title . "</a> <!--" . $description . "--></div> <br>"; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>@breakingnews: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
$feed = "http://www.nytimes.com/services/xml/rss/nyt/pop_top.xml"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
$image = $YODEL->image; | |
//echo"<div class ='masonry_item' style='background: #FFFFFF;'><a href='". $link ."'>" . "RUT: " . $pubDate . "<br />" . $title . "</a> <!--" . $description . "--></div> <br>"; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>NYT: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
$feed = "http://news.yahoo.com/rss"; | |
$xml = simplexml_load_file($feed); | |
$count = 0; | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
$image = $YODEL->image; | |
$imageURL = $image->url; | |
$media = $YODEL->media; | |
$count += 1; | |
// echo "<h1>count: </h1>" . $count; | |
// echo "<h1>media: </h1>" . $media; | |
// echo "<h1>imageURL: </h1>" . $imageURL; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>YAHOO: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
/* | |
//this is how you get anything inside the <image> tree... | |
foreach($xml->channel->image as $hello){ | |
$title = $hello->title; | |
$link = $hello->link; | |
$url = $hello->url; | |
echo "<h1>image: </h1>" . $title . $link . $url; | |
} | |
*/ | |
$feed = "http://news.yahoo.com/rss/world"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>YAHOO: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
//ny times front page: http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml | |
$feed = "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
//BEG GET ELEMENT WITHIN <media:content | |
/* | |
$xml1 = '<item> | |
<media:content type="image/jpeg" url="http://www.ALEJANDROSPENSWA.com" /> | |
</item>'; | |
$theContent = @new SimpleXMLElement($xml1); | |
$attributes = $theContent->content->attributes(); | |
echo $attributes['url']; //outputs: my url | |
echo "<h1>URL1: " . $attributes['url'] . "</h1>"; //outputs: my url | |
*/ | |
//END | |
$nytimage = $YODEL->{'media:description'}; | |
//echo "nytimage: " . $nytimage; | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>NYT frontpg: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
$feed = "http://online.wsj.com/xml/rss/3_7041.xml"; | |
$xml = simplexml_load_file($feed); | |
foreach($xml->channel->item as $YODEL){ | |
$title = $YODEL->title; | |
$description = $YODEL->description; | |
$link = $YODEL->link; | |
$pubDate = $YODEL->pubDate; //should be able to use Rutgers pubDate to sort newest.... get a better Drudge feed to do the same | |
echo " | |
<div class='box'> | |
<div class ='newz_caption' style='background: #FFFFFF;'> | |
<h3>" . $title . "</h3> | |
<h5>WSJ: " . $pubDate . "</h5> | |
<p> " . $description . " </p> | |
<p> | |
<a class='btn btn-primary' href='" . $link . "'> Source </a> | |
<a class='btn' href='#'>Thumbs Up </a> | |
</p> | |
</div> | |
</div> | |
<br>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment