2012-07-29 106 views
0

我從外部網站使用捲曲和絕對鏈接顯示運動裝置效果很好。問題是外部網站不能正確排序結果。我可以這樣做,也許是指外部頁面的標籤。從外部網站排序結果

這是我的代碼:

<?php 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://www.sportingpulse.com/mobile/mobile.cgi?a=CL&aID=2307"); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
$result = curl_exec($ch); 
curl_close($ch); 
$result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://www.sportingpulse.com/mobile/$2$3', $result); 
echo $result 
?> 

這是我的年齡組喜歡排序結果(可能使用類=「列表名稱」)或任何其他建議:

 <ul class="options" data-role="listview"> 
<li role="heading" data-role="list-divider">Please choose your Competition</li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223601"><div class="list-name">2012 Winter 23 Girls A</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223608"><div class="list-name">2012 Winter 18 Boys A</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223691"><div class="list-name">2012 Winter 23 Girls AR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223637"><div class="list-name">2012 Winter 18 Boys AR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223578"><div class="list-name">2012 Winter 18 Boys B</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223711"><div class="list-name">2012 Winter 23 Girls B</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223620"><div class="list-name">2012 Winter 18 Boys BR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223661"><div class="list-name">2012 Winter 18 Girls BR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223573"><div class="list-name">2012 Winter 18 Boys C</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223639"><div class="list-name">2012 Winter 23 Girls BR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223679"><div class="list-name">2012 Winter 23 Girls C</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223676"><div class="list-name">2012 Winter 20 Boys A</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223579"><div class="list-name">2012 Winter 20 Boys AR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223686"><div class="list-name">2012 Winter 23 Boys A</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223592"><div class="list-name">2012 Winter 20 Boys B</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223704"><div class="list-name">2012 Winter 23 Boys AR</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223662"><div class="list-name">2012 Winter 23 Boys B</div></a></li> 
     <li><a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;aID=2307&amp;cID=223685"><div class="list-name">2012 Winter 23 Boys BR</div></a></li> 
</ul> 

回答

0

這工作按字母順序排列包含在class =「option」中的鏈接,該鏈接對年齡組進行排序

sort('ul.options>li', 'a'); 
function sort(list, key) { 
    $($(list).get().reverse()).each(function(outer) { 
     var sorting = this; 
     $($(list).get().reverse()).each(function(inner) { 
      if($(key, this).text().localeCompare($(key, sorting).text()) > 0) { 
       this.parentNode.insertBefore(sorting.parentNode.removeChild(sorting), this); 
      } 
     }); 
    }); 
}