【发布时间】:2015-11-18 21:24:19
【问题描述】:
直到这周,我才能够使用一个简单的 html dom 解析器从谷歌学者中抓取内容。 (是的,我知道他们不希望人们这样做,因此没有 API)。
但在过去一两天内,它已停止显示内容。尝试简单的file_get_html 或 url 时出现以下错误:
服务器错误我们很抱歉,但似乎出现了 处理您的请求时出现内部服务器错误。我们的工程师 已收到通知并正在努力解决问题。请尝试 稍后再来。
我见过其他的questions,但解决方案大多是 R 特定的或使用 cURL。有没有人建议调整我的简单 php 函数,尤其是调用两次?还是我不走运,因为 Google 现在正在关闭这扇门?
我的代码:
<?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>
【问题讨论】:
-
你真的应该问谷歌......不幸的是
标签: php html-parsing internal-server-error google-scholar