##わからないこと
いつもお世話になっております。
この度、以前では取得できていたクローリング元のサイトのURLが取得できなくなったのですが、その原因がわからず相談をさせていただきました。
##コード
javascript
1var page = require('webpage').create(); 2var system = require('system'); 3var args = system.args; 4 5var url = args[1]; 6if (url == undefined) { 7 phantom.exit(); 8} 9 10page.open(url, function(status) { 11 if (status === 'success') { 12 page.switchToFrame(0); 13 var body = page.evaluate(function() { 14 return '<html>' + document.getElementsByTagName('html')[0].innerHTML + '</html>'; 15 }); 16 } 17 phantom.exit(); 18}); 19 20
php
1public function handle() { 2 $url = 'http://www.kaigokensaku.mhlw.go.jp/01/index.php?action_kouhyou_pref_search_list_list=true&PrefCd=01&OriPrefCd=01&method=pager&p_sort_name=47&p_order_name=1'; 3 $xml = $this->phantomjsHtml($url); 4} 5 6public function phantomjsHtml($url) { 7 $arr = []; 8 // 文字列にてhtmを出力 9 exec('C:\X_DRIVE\asp\home\laravel\vendor\bin\phantomjs.exe C:\X_DRIVE\asp\home\laravel\public\js\crawler.js '.$url, $arr); 10 if(!$arr){ 11 \statusFailure(); 12 } 13
上記のうち、「statusFailure();」を通っているので、URLをもとにhtml構造を取得できていなところまではわかるのですが・・・
##追記
コマンドラインで直接実行してみましたら、下記のエラーが出ました。
PHP Warning: Unexpected character in input: '' (ASCII=7) state=0 in C:\laravel\vendor\bin\phantomjs.exe on line 359 Warning: Unexpected character in input: '' (ASCII=7) state=0 in C:\laravel\vendor\bin\phantomjs.exe on line 359 PHP Parse error: syntax error, unexpected 'G4晦D' (T_STRING) in C:\laravel\vendor\bin\phantomjs.exe on line 359 Parse error: syntax error, unexpected 'G4晦D' (T_STRING) in C:\home\laravel\vendor\bin\phantomjs.exe on line 359
何卒よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー