Jump to content

Archived

This topic is now archived and is closed to further replies.

drisate

Table to Array

Recommended Posts

Hey guys i need help with a CURL code. I need to retreive all the data in a table located at http://www.listenlive.nl/tvgenre.php?g=1&page=0 and parse the data to finish with an array that looks like this:

$row[0][station_name] = '3BTV';
$row[0][stream_link] = '420';
$row[0][stream_type] = 'wma';
$row[0][country] = 'United Kingdom';
$row[0][genre][0] = 'Variety';
$row[0][genre][1] = 'Alternative';
$row[0][genre][2] = 'Culture';
$row[0][rating] = '1/5';


I need that for each rows of the table where the first array number would increment $row[1], $row[2] ...
My PHP code is incomplete. I currently have a loop for all the TR's of the page ... and when i loop all the TD's inside the TR's it returns a load of crap ... I am unsure where to go from here. Any help would be apreciated thx


This is my code:
 

$ch = curl_init();
$categ[url] = 'http://www.listenlive.nl/tvgenre.php?g=1&page=0';
curl_setopt($ch, CURLOPT_URL, $categ[url]);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_setopt($ch, CURLOPT_REFERER, $categ[url]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $nav);
$data2 = curl_exec($ch);
$dom2 = new DOMDocument();
libxml_use_internal_errors(true);
$dom2->loadHTML($data2);
$trs = $dom2->getElementsByTagName('tr');
foreach ($trs as $tr) {
echo "<pre>";
print_r($tr);
echo "</pre>";
}

Share this post


Link to post
Share on other sites

Well as you can imagine, the dump of the $tr var is very big ... would be a lot easyer if you would just execute the provided code.

Share this post


Link to post
Share on other sites

Well as you can imagine, the dump of the $tr var is very big 

 

So trim it down for us.  Show us the relevant information.

Share this post


Link to post
Share on other sites

×
×
  • 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.