我使用DomDoc来拉页面,但由于我的服务器位于美国,因此它会拉出美国页面,而不是英国页面。
是否有机会欺骗它拉动英国的页面?
<?php
//above will be pulingthe race data
$pagecode = "1.119512711";
$url = "http://form.timeform.betfair.com/racecard?id=".$pagecode; //WILL NEED TO PULL TOMORROWS DATE AS DD-MM-YYY
echo $html = file_get_contents($url);
$dom = new DOMDocument();
@$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$xpath = new DOMXPath($dom);
//pull the individual cards for the day
//li class="rac-cardsclass="ix ixc"
$getdropdown = '//ul[contains(@class, "runner-body-container")]/li/div/ul';
$getdropdown2 = $xpath->query($getdropdown);
//loop through each individual card
foreach ($getdropdown2 as $dropresults) {
$repl = preg_replace('/\h*[^ a-zA-Z].*$/m', '', trim($dropresults->childNodes->item(8)->textContent))."<br />";
$dropresults->childNodes->item(18)->textContent."<br />";
$dropresults->childNodes->item(20)->textContent."<br />";
}
?>
答案 0 :(得分:0)
尝试在英国使用服务器。您还可以使用代理从代理位置接收文件。
代理方法:在StackOverflow上查看此问题,了解如何: file_get_contents behind a proxy?