douli8428 2018-10-06 10:48
浏览 33

curl点击url但服务器没有收到数据

Can anyone help me? I am tring to hit a website using curl.
My code is as follows:

$data = array(
    'utm_source'=>'Google',
    'utm_medium'=>'Google',
    'utm_campaign'=>'Sales',
    'utm_term'=>'united flights tickets'
);
$data = http_build_query($data, '', '&');
$proxies[] = 'user:password@71.6.46.151:443';
$proxies[] = 'user:password@14.102.19.206:61217';
$proxies[] = 'user:password@187.95.230.65:8080';
$url = 'https://www.example.com/index.php?'.$data;

$ch = curl_init();

if (isset($proxy)) { // If the $proxy variable is set, then
    curl_setopt($ch, CURLOPT_PROXY, $proxy); // Set CURLOPT_PROXY with proxy in $proxy variable
}

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:5.0)    Gecko/20100101 Firefox/5.0');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.google.com');
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 500);
curl_setopt($ch, CURLOPT_URL, $url);

$results = curl_exec($ch);  // Execute a cURL request

if (curl_error($ch)) {
    $error_msg = curl_error($ch);
}

$info = curl_getinfo($ch);
curl_close($ch);

print_r($error_msg);
print_r($info);
print_r($results);

It hits the website and also displayed in the Google Analytics account, but the only problem is that the refferer and source showing "direct" in Google Analytics.
If there is any other way to achive this, please tell me.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch