如何向网址发送请求: http://www.flashi.tv/embed.php?v=HitSportsNet41125 使用引荐来源http://sportsembed.com/stream-1.php在端口80上 抓取源代码?
我可以在PHP中使用cURL吗?
答案 0 :(得分:1)
cURL是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);
答案 1 :(得分: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);
我知道推荐人的拼写错误,这只是我们所有人都必须要做的事情:/
答案 2 :(得分:0)
是的,curl可以做到这一点。
谷歌搜索php curl set referrer
提供了一些很好的提示:
$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);