|
-
Sep 15th, 2007, 11:15 AM
#1
Thread Starter
Frenzied Member
Help parsing artist,songname and image url from remote html
Hi all there is a remote html page that has artist,songname and image url . I want to get these infromation when ever i pull that page . could any one show me how this can be done.Thanks
Note: the information that i want to extract are shown in bold.
Note: the html is dynamic and changes
Html of page that i want to pull every few seconds:
<table border=0 width="280" bgcolor="#FFFFFF" cellpadding=5><tr><td align="center" width="80">
<a href="http://www.somesite.com" target="_blank"><img border="0" src="http://www.somesite.com/static/artists/kiosk.jpg" border="0"></a></td><td width="100" style="font-family:Arial; font-size:12px; color:#000000;">artist<br>"songname"</td><td valign="top"><table><tr><td><table><tr><td><a href="http://www.somesite.com" target="_blank"><img border="0" src="http://www.somesite.com/static/artists/rj_box.jpg" width="30" height="30" border="0"></a></td><td><font size="1" face="Arial" color="red"><b>RADIO<br>ABCDE</b></font></td></tr></table></td></tr><tr><td><a href="http://www.somesite.com/listen" target="_blank"><img border="0" src="http://www.somesite.com/images/nwp96k.gif"></a></td></tr><tr><td><a href="http://www.somesite.com/listen" target="_blank"><img border="0" src="http://www.somesite.com/images/nwp128k.gif"></a></td></tr></table></td></tr></table
-
Sep 15th, 2007, 07:58 PM
#2
Stuck in the 80s
Re: Help parsing artist,songname and image url from remote html
What do you mean the HTML is dynamic and changes? Do you mean the bold values change, or does the actual page HTML change?
If the HTML changes each time, there is no way you can write code to parse it.
If the HTML is constant, you could use preg_match() to find instances of /static/artists/(.*).jpg and (.*)<br />"(.*)" to extract those data elements, assuming no other text in the HTML matches these patterns.
-
Sep 15th, 2007, 10:17 PM
#3
Thread Starter
Frenzied Member
Re: Help parsing artist,songname and image url from remote html
 Originally Posted by The Hobo
What do you mean the HTML is dynamic and changes? Do you mean the bold values change, or does the actual page HTML change?
If the HTML changes each time, there is no way you can write code to parse it.
If the HTML is constant, you could use preg_match() to find instances of /static/artists/(.*).jpg and (.*)<br />"(.*)" to extract those data elements, assuming no other text in the HTML matches these patterns.
Thanks for your reply. The html is the same only the bold parts changes. so i want the php some how pull that html page and then extract the bold data.But i don't know how to tell php to get that html and then get the bold data for me.Hope some one show me how this can be done.Thanks
Note: the html is in remote server and i have no controle over it
-
Sep 16th, 2007, 05:45 AM
#4
Re: Help parsing artist,songname and image url from remote html
-
Sep 16th, 2007, 01:50 PM
#5
Thread Starter
Frenzied Member
Re: Help parsing artist,songname and image url from remote html
 Originally Posted by visualAd
Are you using PHP 5?
Thanks for reply.The server that i want to install the script is running PHP Version 4.4.0.
-
Sep 18th, 2007, 09:14 PM
#6
Thread Starter
Frenzied Member
Re: Help parsing artist,songname and image url from remote html
i tried this solution but it doesn't output the image url for me . could any one tell me what i am doing wrong and how to fix it.Thanks
PHP Code:
<?PHP
$html = file_get_contents("http://services.remotesite.com/rss.php?html=280");
preg_match("/<img border=\"0\" src=\"(.*)\" border=\"0\">$/", $html, $urls);
//preg_match("<td width=\"100\" (.*)>(.*)</td>", $html, $tdmatch);
preg_match("/<td width=\"100\" (.*)>(.*)<\/td>/", $html, $tdmatch);
echo "<pre>";
var_dump($urls);
var_dump($tdmatch);
echo "</pre>";
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|