Google Scholar から結果を取得するための 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 リクエストが失敗しました! /var/www/html/scholar/simple_html_dom.php の 78 行目で HTTP/1.0 503 サービスを利用できません
-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"]');
ローカルホストでスクリプトを実行すると動作します。サーバーでスクリプトを実行すると、エラーが発生します
グーグルは通話をブロックしますか?何が問題ですか?
ありがとう