php 获取网页内容,请问为什么用php curl抓取不到网页数据,放在别的服务器上却可以?

用户投稿 49 0

关于“php_curl获取网页”的问题,小编就整理了【2】个相关介绍“php_curl获取网页”的解答:

请问为什么用php curl抓取不到网页数据,放在别的服务器上却可以?

除了curl fsocket也要打开

有些服务器确实是不支持curl

如何使用php中的curl方法向服务器发送post请求?

用PHP向服务器发送HTTP的POST请求,代码如下:

<?php/** * 发送post请求 * @param string $url 请求地址 * @param array $post_data post键值对数据 * @return string */ function send_post($url, $post_data) { $postdata = http_build_query($post_data); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 // 超时时间(单位:s) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; }

到此,以上就是小编对于“php_curl获取网页”的问题就介绍到这了,希望介绍关于“php_curl获取网页”的【2】点解答对大家有用。

抱歉,评论功能暂时关闭!