Web サイトのデータをスクレイピングするアプリケーションがあります。iFrame で Web サイトをスクレイピングしています。フィールドとボタンのあるページにつながるエントリアドレスを持つ同じ iframe から、後続の Web サイトにスクレイピングする必要があります。そのページで、フィールドに数字を入力し、ボタンを押して次のページに移動します。私が抱えている問題は、ボタンを (コード化して) 押すと、ページが読み込まれるのを待たず、そこに何かがある前にスクレイピングすることです。
setTimeOut
とDelay
完全に無視されているようです。
$(document).ready(function() {
$('#startbutton').click(function() {
$('#iframe').attr('src', 'www.pageone.com');
// Here I start a load because I need to wait for the button to become available.
$('#iframe').one('load', function() {
$('#okbutton').click();
});
// This is where it goes wrong. I would assume that it waits for the second page
// to load. But it doesn't. Adding another load block didn't help.
scrapeFunction();
});
});
これらのタイミングを正しくするにはどうすればよいですか?