私は、cheerio を使用して node.js で、元のサイトへのリンクを使用して構築している Web サイト用に 10 個の Web サイトをスクレイピングしようとしています。私の質問は、その情報をどのように取得できるかです。たとえば、最初にボタンのクリックをトリガーしてから DOM を取得します。
第二に、同じDOM構造がすべてのデータを取得していません。あるページの情報を取得していますが、同じDOM構造を持つ別のページの要素を取得していません。任意の助けをいただければ幸いです。
ありがとうございます。 編集1:関連コード
$('#ProductContent').filter(function(){ var price = undefined; var ukulele = false; var model = $(this).find('.ProductSubtitle').text().replace(/\n\s*/g,""); if(model.indexOf(/m/i) != 0){ var description = $(this).find('.RomanceCopy').text().replace(/\n\s*|\r/g,""); . .code removed for brevity and the variables present here are populated . //this children is populated only for one page. children = $(this).find('.SpecsColumn .SpecsTable table tbody').children('tr'); console.log('children: '+children.length) console.log(guitar_url); children.each(function(){ var key = $(this).children('td').first().text(); var value = $(this).children('td').last().text(); specs[key] = value; console.log(specs); });
編集 2: Cherios の初期化
request(guitar_url,function(error,response,html){ if(!error){ var $ = cheerio.load(html); $("#content #right-content").filter(function(){..children and other variables are populated inside here....}) } })