3

每当我https://scholar.google.com/citations?user=N7m4vIQAAAAJ&hl=en在 Safari 和 Google Chrome 的私人窗口中运行该 url 时,Google 都会给出错误。

它仅发生在具有隐私浏览模式的第一个请求上。

有人知道为什么这只发生在特定环境中吗?这种情况从 3 天前就开始了。

-- 错误消息和捕获

Server Error We're sorry but it appears that there has been an internal server error while processing your request. Our engineers have been notified and are working to resolve the issue. Please try again later.

在此处输入图像描述

在此处输入图像描述

- - 添加

头文件包括

http header response Cache-Control: no-cache, must-revalidate Content-Encoding: gzip Content-Type: text/html; charset=UTF-8 Date: Mon, 16 Nov 2015 19:35:39 GMT Expires: Fri, 01 Jan 1990 00:00:00 GMT Pragma: no-cache Server: citations Set-Cookie: NID=73=eF98qod1NpYg7nb03RUToiSiacFgqNoZxQ4CuzqwGlQn53SoR7rHlzO0OExsmYkpRazROCQ3WqKoCsWKFPxp8dZr5pBra6nD1HPcxWUILl9gVAf5Q7GSQc3B0O3TP4gu; expires=Tue, 17-May-2016 19:35:39 GMT; path=/; domain=.google.com; HttpOnly X-Firefox-Spdy: h2 X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block p3p: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." x-content-type-options: no sniff

4

1 回答 1

1

通过在请求 URL 时使用 cookie 解决了该问题。REF:PHP cURL 如何添加用户代理值或克服服务器阻止 cURL 请求?

我使用 php 脚本来检索和放置一些 cookie 选项。

代码片段是

    $curl = curl_init($url);
    $dir                   = dirname(__FILE__);
    $config['cookie_file'] = $dir . '/cookies/' . md5($_SERVER['REMOTE_ADDR']) . '.txt';

    curl_setopt($curl, CURLOPT_COOKIEFILE, $config['cookie_file']);
    curl_setopt($curl, CURLOPT_COOKIEJAR, $config['cookie_file']);

    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($curl);
    curl_close($curl);
于 2015-11-17T23:39:50.433 回答