2012-07-01 55 views
-2

我怎麼能發送請求的URL:在端口80 http://www.flashi.tv/embed.php?v=HitSportsNet41125 帶引薦http://sportsembed.com/stream-1.php 抓取的源代碼?請求帶引薦網址的

我可以在PHP中使用cURL嗎?

+0

是的,捲曲可以做到這一點。 – sandradev

+0

在[手冊](http://uk.php.net/manual/en/function.curl-setopt.php)中很容易找到。 – Quentin

+0

-1 http://www.emilvikstrom.se/whyidownvote.html你有什麼嘗試?你的代碼在哪裏?你有沒有閱讀手冊? –

回答

1

捲曲是在PHP和你的可選模塊可能找不到它每一個安裝即

這裏是PHP核心的東西部分:

$contextOptions=stream_context_create(array(
    "http"=>array(
     "method"=>"GET", 
     "header"=> 
      "Accept-language: en\r\n". 
      "Cookie: foo=bar\r\n". 
      "Referer: http://sportsembed.com/stream-1.php\r\n", 
     "user_agent"=>"CrawlingBot v1.0" 
    ) 
)); 
file_get_contents("http://www.flashi.tv/embed.php?v=HitSportsNet41125", /*include path*/ false, $contextOptions); 
+0

如果這解決了您的問題,不要忘記標記答案爲接受(投票按鈕下的綠色複選標記)。 –

0
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http:// www.flashi.tv/embed.php?v=HitSportsNet41125'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_REFERER, 'http:// sportsembed.com/stream-1.php'); 
$html = curl_exec($ch); 

我知道引用拼寫錯誤,它只是我們大家都不得不生活:/

+0

我實際上已經從PHP文檔頁面中的示例中解除了它。 http://php.net/manual/en/function.curl-setopt.php – Rawkode

+0

謝謝..我已經查找了指南...解決了它...隨你的參考 –

0

是的,捲曲可以做到這一點。

谷歌搜索​​給出了一些很好的提示:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/2'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_REFERER, 'http://www.example.com/1'); 
$html = curl_exec($ch); 
+0

謝謝..我已經擡起頭來代碼在指導.. –