Google Scholar服务器错误HTML解析器

时间:2015-11-18 21:24:19

标签: php html-parsing internal-server-error google-scholar

直到本周我才能使用简单的html dom解析器来刮掉谷歌学者的内容。 (是的,我知道他们不希望人们这样做,因此没有API)。

然而在过去的一两天里,它停止了显示内容。尝试简单的file_get_html或网址时,会出现以下错误:

  

服务器错误我们很抱歉,但似乎有一个   处理您的请求时出现内部服务器错误我们的工程师   已经通知并正在努力解决问题。请尝试   再来一次。

我在那里看到了其他questions,但解决方案主要是R特定的或正在使用cURL。有没有人有调整我简单的PHP功能的建议,特别是要调用两次?或者,由于谷歌正在关闭这扇门,我运气不好吗?

我的代码:

<?php require_once('assets/functions/simple_html_dom.php');
$google_id = get_post_meta($post->ID, 'ecpt_google_id', true);
$google = new simple_html_dom;
$google_url = 'http://scholar.google.com/citations?user=' . $google_id . '&pagesize=10';
$older_pubs = 'http://scholar.google.com/citations?user=' . $google_id;
$google = file_get_html($google_url);

foreach($google->find('tr.gsc_a_tr') as $article) {
    $item['title']  = $article->find('td.gsc_a_t a', 0)->plaintext;
    $item['link']   = $article->find('a.gsc_a_at', 0)->href;
    $item['pub']    = $article->find('td.gsc_a_t .gs_gray', 1)->plaintext;
    $item['year']   = $article->find('td.gsc_a_y', 0)->plaintext;

    ?>
    <p class="pub"><b><a href="http://scholar.google.com<?php echo $item['link'];?>"><?php echo $item['title']; ?></a></b></p>
    <h6 class="pub"><?php echo $item['year']; ?>, <?php echo $item['pub']; ?></h6>


    <?php } ?>
<p align="right"><b><a href="<?php echo $older_pubs; ?>">View Publications</a></b></p>

1 个答案:

答案 0 :(得分:1)

如果不再接受Cookie,则无法访问Google学者。 一个&#34;服务器错误&#34;如果您尝试使用curl / wget /...

进行访问

尝试接受cookie,对于curl / php,请参阅: Google Server gives a server error with the first request in private browsing mode

然后加载页面两次(首先接受cookie和服务器错误,第二次获取内容。)