相关疑难解决方法(0)

如何在PHP中重置Curl变量?

我想连续做一些Curl调用,第一个是帖子,但是对于第二个我只想加载页面而不发布任何事情.

这是我的代码,它不起作用

$url = 'http://www.xxxx.com/results.php';
$curl_handle=curl_init();
curl_setopt ($curl_handle, CURLOPT_PROXY, $tor);
curl_setopt( $curl_handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl_handle, CURLOPT_REFERER, $referer);

curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); 
$data = 'Manufacturer=1265';
curl_setopt($curl_handle, CURLOPT_POST,1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS ,$data);
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);

$dest = 'http://www.xxxx.com/search.php';
curl_setopt($curl_handle, CURLOPT_GET, 1);
curl_setopt($curl_handle, CURLOPT_URL, $dest);
$result = curl_exec ($curl_handle);
curl_close ($curl_handle); 
echo $result;
Run Code Online (Sandbox Code Playgroud)

当我关闭卷曲手柄并为第二个请求打开一个新的时,它工作正常.我不认为这是最好的做法吗?

php curl

4
推荐指数
1
解决办法
4670
查看次数

标签 统计

curl ×1

php ×1