Trouble with file_get_contents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jiggens
Forum Commoner
Posts: 37
Joined: Sun Jul 08, 2007 4:49 pm

Trouble with file_get_contents

Post by jiggens »

I am trying to setup hyperlink using get_file_contents for the url http://bloomburg.com/news/breakingnews/ I also want to have it update each time i thought i had it but i keep getting NO DATA its dying on me.

Code: Select all

 
<?php // Corys Tempblog_bloomberg.php
 
// THE DATA FEED
$home  = 'http://www.bloomberg.com/news/breakingnews/';
 
// GET THE FEED
$data  = file_get_contents($home);
 
// GET RID OF THE UNWANTED STUFF
$xstr1 = '<div class="contentbox">';
$xstr2 = '</div>';
$text  = explode($xstr1, $data);
$data  = $text[1];
$text  = explode($xstr2, $data);
$data  = $text[0];
 
// FIND FIRST USEFUL INFORMATION
$psum  = '<p class="summ">';
$pos   = strpos($data, $psum);
if ($pos === FALSE) die('NO DATA');
$data  = substr($data, $pos);
 
// CLEAN UP THE LINKS
$data  = str_replace('/apps/news', 'http://www.bloomberg.com/apps/news', $data);
 
// USE THE PARAGRAPH TAGS TO BREAK THIS TEXT INTO AN ARRAY
$data  = str_replace('</p>', '', $data);
$data  = str_replace('<br>', '', $data);
$xstr3 = '<p class="summ">';
$text  = explode($xstr3, $data);
 
// ITERATE OVER THE TEXTS (COUNT LIMITED)
foreach ($text as $pointer => $data)
{
   if ($pointer > 5) break;
   echo "<p>";
   echo $data;
   echo "</p>\n";
}
?>
 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Trouble with file_get_contents

Post by requinix »

Bloomberg ToS wrote:YOU MAY NOT COPY, REPRODUCE, RECOMPILE, DECOMPILE, DISASSEMBLE, REVERSE ENGINEER, DISTRIBUTE, PUBLISH, DISPLAY, PERFORM, MODIFY, UPLOAD TO, CREATE DERIVATIVE WORKS FROM, TRANSMIT, OR IN ANY WAY EXPLOIT ANY PART OF THE SERVICE, EXCEPT THAT YOU MAY DOWNLOAD MATERIAL FROM THE SERVICE AND/OR MAKE ONE PRINT COPY FOR YOUR OWN PERSONAL, NONCOMMERCIAL USE, PROVIDED THAT YOU RETAIN ALL COPYRIGHT AND OTHER PROPRIETARY NOTICES.
...
ADDITIONALLY, YOU MAY NOT OFFER ANY PART OF THE SERVICE FOR SALE OR DISTRIBUTE IT OVER ANY OTHER MEDIUM INCLUDING BUT NOT LIMITED TO OVER-THE-AIR TELEVISION OR RADIO BROADCAST, A COMPUTER NETWORK OR HYPERLINK FRAMING ON THE INTERNET WITHOUT THE PRIOR WRITTEN CONSENT OF BLP.
http://bloomberg.com/notices/tos.html
jiggens
Forum Commoner
Posts: 37
Joined: Sun Jul 08, 2007 4:49 pm

Re: Trouble with file_get_contents

Post by jiggens »

Yeah but you can link to the site, it says


Without limiting other provisions contained in our TOS, you may include a link(s) on your Web site to Bloomberg.com's publicly accessible Web pages (i.e., any Web page which does not require a login and password and/or restrict access). You may not link to Bloomberg.com any site containing an inappropriate, profane, defamatory, infringing, obscene, indecent or unlawful topic, name, material or information that violates any applicable intellectual property, proprietary, privacy or publicity rights.
Post Reply