2016-11-29 92 views
0

我用nwjs(版本0.18.8),並且我在mangafox.me上做了一個請求來做一個mangareader。用node.js請求和獲取奇怪字符颳去網站

它與http://mangafox.me/directory/

當我嘗試做一個請求的漫畫形象在這樣一個http://mangafox.me/manga/onepunch_man/vTBD/c066/1.html我得到這些奇怪的符號:

{SF 6 W#Y \ AI(tYdϯM%9 @ CW〜I(vںʑytk2z o y 。^〜wɌ e Ҳ ]?c Kf =v 0 3?y`Y _̘gY|fY \ Q2 M nV iz g b$W _a c C5

我怎樣才能解決這個

回答

1

沒關係X)其實那只是輸出在ZIP壓縮,所以如果你想解決這個問題,如果你有同樣的問題,只是添加的gzip:在要求真頭部例如:

request({url: '*****', gzip: true}, function(err, res, html){ 

    if (!error && response.statusCode == 200) { 

    //Do something 

    } 

}); 
0

對於這種簡單的事情,您不需要node.js。刮取網站的最簡單方法是將其加載到隱藏的iframe中,然後循環訪問您需要的文檔的元素數組。

加載該文件給出你的一切在這樣的陣列...

Frame.contentWindow.document.forms 

Frame.contentWindow.document.scripts 

Frame.contentWindow.document.styleSheets 

Frame.contentWindow.document.embeds 

Frame.contentWindow.document.cookie 

Frame.contentWindow.document.images 

Frame.contentWindow.document.links 

,...等