file_get_contents函数是来下载网页,传递链接自动发送get请求,并将网页内容下载下来
post请求,使用代理下载,定义User-Agent等等,大多使用curl,其实file_get_contents也可以的
代码如下:
function Post($url, $post = null)
{
$context = array();
if (is_array($post))
{
ksort($post);
$context['http'] = array
(
'timeout'=>60,
'method' => 'POST',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
$data = array
(
'name' => 'test',
'email' => 'test@gmail.com',
'submit' => 'submit',
);
echo Post('http://www.yifu.info', $data);
1119

被折叠的 条评论
为什么被折叠?



