我使用 curl 和绝对链接从外部站点显示运动器材,效果很好。问题是外部站点没有正确排序结果。我可以这样做,也许是指外部页面的标签。
这是我的代码:
<?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
?>
这是我希望按年龄组排序的结果(可能使用 class="list-name")或任何其他建议:
<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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&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&aID=2307&cID=223685"><div class="list-name">2012 Winter 23 Boys BR</div></a></li>
</ul>