編程php抓取器。我想抓取一些文本,然後將抓取的內容與上次掃描時存儲在我的數據庫中的內容進行比較。一切正常。但我想掃描網址在哪裏是一個「過濾器」的形式,所以它張貼一些數據,因此我不能看到確切的網址進行掃描。有沒有辦法,我的腳本會提交我想要的數據,因此它會顯示我想要的腳本內容,然後我可以抓取內容?php grabber - 提交腳本
它像
$url = 'myurl';
$data=get_data($url);
$grabbed=strip_tags(get_match('some regex',$data);
function get_data($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function get_match($regex,$content)
{
preg_match($regex,$content,$matches);
return $matches[1];
}
這個偉大的工程,但我需要在該網址上,這將使我的內容訪問該表單submison腳本。那可能嗎?
非常感謝,
Martin。
更新:
<?php
//url
$url = "http://data.skga.sk/Tournaments.aspx";
//get the page content
$content = get_data($url);
echo $content;
//gets the match content
function get_match($regex,$content)
{
preg_match($regex,$content,$matches);
return $matches[1];
}
//gets the data from a URL
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "ctl00%24RightContentPlaceholder%24dpTo=20.10.2012");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
這是我現在的代碼。但我仍然不知道如何解決它。當我在瀏覽器中執行http://data.skga.sk/Tournaments.aspx?ctl00%24RightContentPlaceholder%24dpTo=20.10.2012時很好。但是當我運行這個PHP我可以看到默認頁面
http://ligafiriem.eu/grabber/grabber.php這是我的腳本的結果 –