You are here: Re: Get data between HTML Tags « PHP Language « IT news, forums, messages
Re: Get data between HTML Tags

Posted by Tyrone Slothrop on 09/05/05 17:25

On Mon, 5 Sep 2005 02:03:41 -0400, "Optonline" <someone@aol.com>
wrote:

>I'm looking to get the baseball score between the html tags on yahoo and
>create my own rows with just the data.
>
>So far I have this code
>-----------------------------------------------------------
>$data = file_get_contents('http://sports.yahoo.com/');
>list(, $data_split) = explode('<td width="50%" class="yspscores">', $data,
>2);
>list($data2, ) = explode('</a></td>', $data_split, 2);
>$data2 = strip_tags($data2);
>echo $data2;
>-------------------------------------------------------
>
>It gives me all the results but I want to do a loop that will find the first
>row of scores create a new row and put the data in the new row then find the
>next row of scores create another new row and insert the data and continue
>that pattern to the end.
>
>Thanks

Why not use file(), which treats each line as an element of an array?
Of course this assumes that each score is on a line.

$file = file("http://sports.yahoo.com");
foreach ($file as $line) {
if (strstr($line, 'ypscores')) {
// your code here
// build your html string
}
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация