Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取两个标记之间的元素简单Html Dom_Php_Dom_Web Scraping_Simple Html Dom - Fatal编程技术网

Php 如何获取两个标记之间的元素简单Html Dom

Php 如何获取两个标记之间的元素简单Html Dom,php,dom,web-scraping,simple-html-dom,Php,Dom,Web Scraping,Simple Html Dom,这是我的Html <b><font color="Red">Flash Player 720p HD Quality Online Links</font></b> <br> <br> <a href="http://bestarticles.me/jaana-na-dil-se-door/?si=5325359" target="_blank">Jaana Na

这是我的Html

<b><font color="Red">Flash Player 720p HD Quality Online Links</font></b>
        <br>
        <br>
        <a href="http://bestarticles.me/jaana-na-dil-se-door/?si=5325359" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 1</a>
        <br>
        <a href="http://bestarticles.me/jaana-na-dil-se-door/?si=5325360" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 2</a>
        <br>
        <br>
        <b><font color="Red">Dailymotion 720p HD Quality Online Links</font></b>
        <br>
        <br>
        <a href="http://bestarticles.me/jaana-na-dil-se-door/?si=k4r2rHPOgem8yAlGqjj" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 1</a>
        <br>
        <a href="http://bestarticles.me/jaana-na-dil-se-door/?si=k63MLC2Vq6fxsPlGqjp" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 2</a>
        <br>
        <br>
        <b><font color="Red">TVLogy 720p HD Quality Online Links</font></b>
        <br>
        <br>
        <a href="http://reviewtv.in/star-plus/?si=YD29025" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 1</a>
        <br>
        <a href="http://reviewtv.in/star-plus/?si=YD29026" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video- Part 2</a>
        <br>
        <br>
        <b><font color="Red">Letwatch 720p HD Quality Online Links</font></b>
        <br>
        <br>
        <a href="http://www.tellycolors.me/star-plus/?si=j3vpekz3jeiv" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video - Part 1</a>
        <br>
        <a href="http://www.tellycolors.me/star-plus/?si=bdjg53bz9gdi" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video - Part 2</a>
        <br>
        <br>
        <b><font color="Red">Vidwatch 720p HD Quality Online Links</font></b>
        <br>
        <br>
        <a href="http://hd-rulez.info/vidwatch.php?id=73sbn356g9nc" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video - Part 1</a>
        <br>
        <a href="http://hd-rulez.info/vidwatch.php?id=73x796cifyvq" target="_blank">Jaana Na Dil Se Door 6th February 2017 Watch Online Video - Part 2</a>
        <br>
        <br>
这就是我正在做的。首先我转义了所有

标记,然后在所有
标记上循环,然后我试图通过$b->next_sibling()获得
标记的下一个同级,但它不起作用,因为通过转义

标记,元素的索引未更新。这是我的密码

$html = str_get_html($html);
$content = $html->find('div.postcontent',0);

   //escape all br
    foreach($content->find('br') as $br){
        $br->outertext = '';
    }

    foreach($content->find('b') as $key => $b){


        echo $b->plaintext;

    }

请帮我用另一种策略废弃
标签。谢谢

我不知道还有没有其他更简单的方法。但只要每个
标记后面正好有两个
标记,该代码就会给出您想要的输出

    $aCount = 0;
    $result = array();
    foreach($content->find('b') as $key => $b){
        $index = $b->plaintext;  
        for($i=0;$i<2;$i++){
            $result[$index][] = $content->find('a',$aCount++)->href;
        }       
    }  
    print_r($result);

我不知道还有没有其他更简单的方法。但只要每个
标记后面正好有两个
标记,该代码就会给出您想要的输出

    $aCount = 0;
    $result = array();
    foreach($content->find('b') as $key => $b){
        $index = $b->plaintext;  
        for($i=0;$i<2;$i++){
            $result[$index][] = $content->find('a',$aCount++)->href;
        }       
    }  
    print_r($result);
Array
(
    [Flash Player 720p HD Quality Online Links] => Array
        (
            [0] => http://bestarticles.me/jaana-na-dil-se-door/?si=5325359
            [1] => http://bestarticles.me/jaana-na-dil-se-door/?si=5325360
        )

    [Dailymotion 720p HD Quality Online Links] => Array
        (
            [0] => http://bestarticles.me/jaana-na-dil-se-door/?si=k4r2rHPOgem8yAlGqjj
            [1] => http://bestarticles.me/jaana-na-dil-se-door/?si=k63MLC2Vq6fxsPlGqjp
        )

    [TVLogy 720p HD Quality Online Links] => Array
        (
            [0] => http://reviewtv.in/star-plus/?si=YD29025
            [1] => http://reviewtv.in/star-plus/?si=YD29026
        )

    [Letwatch 720p HD Quality Online Links] => Array
        (
            [0] => http://www.tellycolors.me/star-plus/?si=j3vpekz3jeiv
            [1] => http://www.tellycolors.me/star-plus/?si=bdjg53bz9gdi
        )

    [Vidwatch 720p HD Quality Online Links] => Array
        (
            [0] => http://hd-rulez.info/vidwatch.php?id=73sbn356g9nc
            [1] => http://hd-rulez.info/vidwatch.php?id=73x796cifyvq
        )

)