خرید بک لینک

Vote count: 0

I need some help with my code. I have a problem with parsing the elements from the html tags, there are two different html tags I have in my html page which there are <a id="link1" and <a id="streams".

When I try this:

$streams_url = $domdoc->getElementsByTagName('a');

foreach($streams_url as $a)
{
   $url[0] = $a->getAttribute("href");
   print_r($url);
}

Here is the full code:

<?php
ini_set('max_execution_time', 300);
//error_reporting(0);
$errmsg_arr = array();
$errflag = false;

function getState($string)
{
  $ex = explode(" ",$string);
  retu $ex[1];
}
$baseUrl = file_get_contents('http://myserverip/get-listing.php');

$domdoc = new DOMDocument();
$domdoc->strictErrorChecking = false;
$domdoc->recover=true;
$domdoc->loadHTML($baseUrl);

$streams_url = $domdoc->getElementsByTagName('a');

foreach($streams_url as $a)
{
   $url[0] = $a->getAttribute("href");
   print_r($url);
}
?>

I will get the full elements from the both html tags <a id="link1" and <a id="streams".

Here is the output:

Array ( [0] => http://myserverip/get-listing.php?chaels=BBC One S East&id=101 ) 
Array ( [0] => rtmp://www.testserver.com/bbc1 ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=BBC Two&id=102) 
Array ( [0] => rtmp://www.testserver.com/bbc2 ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=ITV&id=103 )
Array ( [0] => rtmp://www.testserver.com/itv1 ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=Chael 4&id=104 ) 
Array ( [0] => rtmp://www.testserver.com/chael4 ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=Chael 5&id=105 ) 
Array ( [0] => rtmp://www.testserver.com/chael5 ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=Sky One&id=106 ) 
Array ( [0] => rtmp://www.testserver.com/skyone ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=Sky Living&id=107 ) 
Array ( [0] => rtmp://www.testserver.com/skyliving ) 
Array ( [0] => http://myserverip/get-listing.php?chaels=Sky Atlantic&id=108 ) 
Array ( [0] => rtmp://www.testserver.com/skyatlantic )

I want to get the elements from the streams tags which I want to achieve this:

Array ( [0] => rtmp://www.testserver.com/bbc1 ) 
Array ( [0] => rtmp://www.testserver.com/bbc2 ) 
Array ( [0] => rtmp://www.testserver.com/itv1 ) 
Array ( [0] => rtmp://www.testserver.com/chael4 ) 
Array ( [0] => rtmp://www.testserver.com/chael5 ) 
Array ( [0] => rtmp://www.testserver.com/skyone ) 
Array ( [0] => rtmp://www.testserver.com/skyliving ) 
Array ( [0] => rtmp://www.testserver.com/skyatlantic )

Could you please show me an example of what the best way I could use to parse the elements from the tag called <a id="streams while ignore the elements from the other tag??

asked 48 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 30 خرداد 1395 ساعت: 5:26

صفحه بندی