3段階のプロセスでサイトをスクラップするスクリプト(以下)があります。一度に最大1ページに設定すると効果的です。しかし、私は2時にそれを増加させると、物事は夢中になる。 onFinished火災は私が予想していたよりも早く、ページはまだ完全にロードされていません。私のスクリプトの残りの部分はこれにより休止します。なぜこのことが起こっているのでしょうか?私は最新のバージョン(1.5)を使用していることを追加する必要があります。複数のページでPhantomJS予期しない読み込み動作が発生する
MAX_PAGES = 1
###
changing MAX_PAGES to >1 causes some pages onFinished event to fire before
the page is fully rendered. this is evident by the fact that there are >1 images
for some pages. i havent been able to reproduce using microsoft.com, but on some
pages i was working on the first onLoadFinished seemed to be called before the page
was actually fully loaded based on the look of the rendered images
###
newPage = (id) ->
context = {}
context.id = id
context.step = 0
context.page = require('webpage').create()
context.page.onLoadStarted = ->
context.step++
context.page.onLoadFinished = (status) ->
console.log status
if status is 'success'
context.page.render("#{context.id}_#{context.step}.png")
else
context.page.release()
context.page.open('http://www.microsoft.com')
console.log 'started loading'
newPage id for id in [1..MAX_PAGES]
この例のような再帰呼び出しでない場合、少なくとも次のクロールをトリガーするコールバック。 –
あなたのリンクは壊れています:( – Julien