Bab*_*bar 2 screen-scraping node.js cheerio
我一直试图抓住10个网站,我们正在建立一个网站,链接到原始网站,在node.js上使用cheerio,我们得到的问题是有些网站已经改变,现在使用ajax调用来带来他们的数据,我的问题是我们如何获取该信息,例如首先触发按钮点击然后获取DOM.
其次:相同的dom结构不是获取所有数据,它是检索一个页面的信息,而不是在具有相同DOM结构的另一个页面上获取元素.任何帮助,将不胜感激.
感谢致敬. 编辑1:相关代码
Run Code Online (Sandbox Code Playgroud)$('#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初始化
Run Code Online (Sandbox Code Playgroud)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....}) } })
| 归档时间: |
|
| 查看次数: |
2217 次 |
| 最近记录: |