我正在尝试使用Simple HTML DOM来捕获此分页的最后部分。 这部分:
<a class="paginationNumberStyle page_arrows" data-url="**/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&Nu=P_PARENT_ID&langId=-1&Nao=96&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&Nu=P_PARENT_ID&langId=-1&Nao=96&storeId=10051">
2
</a>
<a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&Nu=P_PARENT_ID&langId=-1&Nao=192&storeId=10051">
3
</a>
<a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&Nu=P_PARENT_ID&langId=-1&Nao=288&storeId=10051">
4
</a>
<a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&Nu=P_PARENT_ID&langId=-1&Nao=384&storeId=10051">
5
</a>
<a class="paginationNumberStyle page_arrows" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&Nu=P_PARENT_ID&langId=-1&Nao=96&storeId=10051">
<img alt="" src="/static/images/layout/triangle-green-right.gif"></a>
</div>
这是我的代码:
if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {
echo $nextPage->href;
我也尝试过:
if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {
我远非Simple Simple DOM的专家,并希望有人知道快速回答。我想知道是不是因为data-url?
答案 0 :(得分:1)
试试这个
if ($nextPage = $dom->find("a[class='paginationNumberStyle page_arrows]", 0)) echo $nextPage->getAttribute('data-url');
答案 1 :(得分:1)
为简单起见,您可以:
$dom->find("a.page_arrows", 0)