douyiyi5284
2013-03-03 21:04
浏览 34
已采纳

simple-html-dom嵌套

I am trying to use Simple HTML DOM to catch the last part of this pagination. This part:

<a class="paginationNumberStyle page_arrows" data-url="**/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051**"> 


    <div class="page-nav">  

                <span>1</span>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051"> 
                    2
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=192&amp;storeId=10051"> 
                    3
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=288&amp;storeId=10051"> 
                    4
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=384&amp;storeId=10051"> 
                    5
                 </a>

        <a class="paginationNumberStyle page_arrows" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051"> 
                    <img alt="" src="/static/images/layout/triangle-green-right.gif"></a>



</div>

Here is my code:

if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {

   echo $nextPage->href;

I have also tried:

if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {

I am far from an expert on Simple HTML DOM and was hoping that someone knew a quick answer. I am wondering if it is because of the data-url?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dtt5830659 2013-03-04 00:47
    已采纳

    For simplicity you can just:

    $dom->find("a.page_arrows", 0)
    
    已采纳该答案
    打赏 评论
  • dongyun65343 2013-03-03 21:09

    Try as this

    if ($nextPage = $dom->find("a[class='paginationNumberStyle page_arrows]", 0)) echo $nextPage->getAttribute('data-url'); 
    
    打赏 评论

相关推荐 更多相似问题