<?php
//$searchterm = "acer predator 21x";
//$searchres = urlencode($searchterm);
$reffer = "https://www.google.com/";
$LOGINURL = "https://www.google.com/search?site=&source=hp&q=acer+predator+21x&oq=acer+predator+21x&gs_l=psy-ab.3...116308.122177.0.126746.0.0.0.0.0.0.0.0..0.0....0...1.1.64.psy-ab..0.0.0.jZC5TmHjRnI
";
$agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
$result = curl_exec ($ch);
if(curl_error($ch)) {
echo "error ".curl_errno($ch)."<br/>";
echo "error ".curl_error($ch);
}
curl_close ($ch);
echo $result;
?>
上午在谷歌搜索使用PHP卷曲和我得到这个错误“的错误在URL中发现3 错误非法字符”,这可能是我试图寻找问题在堆栈上,我找不到任何有用的答案。误差3误差非法字符
你必须在URL – iXCray
结束\ n检查我的回答,我有这样ü可以和\ n在删除多余的空间url –