2014-10-30 91 views
0

我已經在Xampp上安裝了prerender.io,我什麼也沒有看中。剛剛安裝了prerender需要的所有內容,並按照prerender.iohttps://github.com/zf-fr/zfr-prerender的文檔。 因此,可以說,我已經把預渲染在這裏:phantomjs輸出奇怪的字符

/public/assets/services/prerender 

並在控制檯中我跑:

npm install 
node server.js 

ZFR-預渲染的是中間件和我只改一個啄,是指在網址到預渲染:

'prerender_url' => 'http://localhost:3000/public/assets/services/prerender', 

在我的瀏覽器,我去:

本地主機/店鋪/ API /列表_escaped_fragment_ =

從angularJS路由器重定向到/列表/ 1當沒有發現的路由:

ListerApp.config(['$routeProvider', '$httpProvider', '$locationProvider', function($routeProvider, $httpProvider, $locationProvider) { 
$locationProvider.html5Mode(true); 
$locationProvider.hashPrefix('!'); 
$routeProvider 
    .when('/list/:page?', 
     { 
      templateUrl : '/assets/services/partials/list.html', 
      controller : 'ListerCtrl', 
      reloadOnSearch : false, 
      js : ['/assets/min/shoplist_js.min.js', '/assets/min/bootstrap-typeahead.min.js'], 
      //css : [], 
      resolve : { 
       sharedServiceAppData: function($sharedData){ 
        // sharedFactoryAppData will also be injectable in your controller, if you don't want this you could create a new promise with the $q service 
        return $sharedData.promise(); 
        //return; 
       } 
      } 
     } 
    ) 
    .otherwise({ redirectTo: '/list/1' }); 

}]);

控制檯告訴我:

getting public/assets/services/prerender/http://localhost/shop/api/list 
got 200 in 419ms for public/assets/services/prerender/http://localhost/shop/api/list 

但所有的phantomJS回報奇怪的字符。

public function prerenderPost(PrerenderEvent $event) 
{ 
    // This is the response we get from the Prerender service 
    $response = $event->getResponse(); 
    var_dump($response->getHeaders()); 
    var_dump($response->getContent()); 
    // You could get the body and put it in cache 
    // ... 

} 

這些都是集流管,後續代碼var_dump($響應 - > getHeaders()):

array (size=5) 
    0 => 
    array (size=2) 
     'name' => string 'Content-Type' (length=12) 
     'line' => string 'Content-Type: text/html;charset=UTF-8' (length=37) 
    1 => 
    array (size=2) 
     'name' => string 'Content-Encoding' (length=16) 
     'line' => string 'Content-Encoding: gzip' (length=22) 
    2 => 
    array (size=2) 
     'name' => string 'Content-Length' (length=14) 
     'line' => string 'Content-Length: 45' (length=18) 
    3 => 
    array (size=2) 
     'name' => string 'Date' (length=4) 
     'line' => string 'Date: Thu, 30 Oct 2014 18:23:39 GMT' (length=35) 
    4 => 
    array (size=2) 
     'name' => string 'Connection' (length=10) 
     'line' => string 'Connection: close' 

這是一個PHP的var_dump($響應 - >的getContent()):

字符串「<³É(EI±³ÉHML±³Ñ‡PIU)•@」 + 'H'」(長度= 45)

<³É(EI±³ÉHML±³Ñ ‡PIù)•@「+'H'

+1

這應該是一個詳細的錯誤報告https://github.com/zf-fr/zfr-prerender/issues或https://github.com/prerender/prerender/issues – 2014-10-30 23:12:52

+1

是的,多一點關於你所做的事情(以及你訪問的URL)的信息將會很有幫助。謝謝! – 2014-10-31 06:23:09

+0

謝謝,我會編輯這個問題,所以有更多的信息。我會在github上發佈它。我們(或我)稍後可能會參考github討論,以便人們可以在此找到關於此問題的更多信息。 – poashoas 2014-10-31 08:07:39

回答

0

首先,解壓縮並獲得你需要

$response->getBody() 

其次所有的內容,這可能是有用的,以增加去ZFR-prenderer模塊插槽超時的情況下,你有一臺非常非常老舊的電腦。