我创建了一个 php 脚本来从谷歌学者那里检索结果。
function getUserScholarPage($authorId){
$userUrl = "http://scholar.google.it/citations?hl=it&user=" . $authorId . "&view_op=list_works&pagesize=10000";
$html = file_get_html($userUrl);
$rows = $html->find('#gsc_a_b tr[class="gsc_a_tr"]');
return $rows;
}
function getUserScholarBibliography( $rows ){
$publications = array();
foreach( $rows as $row ){
$citations = str_replace(' ', '', $row->find('td[class="gsc_a_c"] a', 0)->plaintext) != '' ? trim($row->find('td[class="gsc_a_c"] a', 0)->plaintext) : 0;
$year = ($row->find('td[class="gsc_a_y"]', 0)->plaintext) ? trim($row->find('td[class="gsc_a_y"]', 0)->plaintext) : 0;
$url = getRealPaperURL('http://scholar.google.it' . $row->find('a[class="gsc_a_at"]',0)->href);
$type = 'ARTICLE';
$title = trim($row->find('a[class="gsc_a_at"]',0)->innertext);
$publications[] = array(
'type' => $type,
'title' => $title,
'authors' => trim($row->find('div[class="gs_gray"]',0)->innertext),
'journal' => trim(preg_replace("'<span[^>]*?>.*?</span>'si", '', $row->find('div[class="gs_gray"]',1)->innertext)),
'citations' => $citations,
'year' => $year,
'url' => $url,
'unique_identifier' => hash('md5', $year . $url . $title)
);
}
return $publications;
}
但是我在调用查询时遇到了问题。我收到一个错误:
警告:file_get_contents(http://scholar.google.it/citations?hl=it&user=XXXXXXX&view_op=list_works&pagesize=10000):打开流失败:HTTP 请求失败!HTTP/1.0 503 Service Unavailable in /var/www/html/scholar/simple_html_dom.php on line 78
-simple_html_dom.php 在第 78 行
https://github.com/samacs/simple_html_dom/blob/master/simple_html_dom.php
致命错误:在第 21 行的 /var/www/html/scholar/scholar-biblio-loader.php 中的非对象上调用成员函数 find()
-scholar-biblio-loader.php 第 21 行
$rows = $html->find('#gsc_a_b tr[class="gsc_a_tr"]');
如果我在 localhost 中运行脚本可以工作。如果我在我的服务器上运行脚本会给我错误
谷歌阻止了通话?问题是什么?
谢谢