Cheerio Web Scrape如何在webscrape内部进行webscrape
我有一个特定的页面,我已经从中获取了一些数据,但为了收集更多的信息,我需要关注另一个href链接来收集更多的数据,而我不知道如何。
这是我到目前为止:
router.get("/:id",function(req,res){ var url = "www.someurl.com" request(url, function (error, response, html){ if (!error && response.statusCode == 200){ $ = cheerio.load(html); $('div.ProductDetails').each(function(){// function for details var self = this; var a = $(this).children().children(); details = a.attr('href'); details = { details:details };
这给我一个链接到细节部分与实际的细节。 我只需要知道如何在刮擦里面刮一下。
details.details
与第一次相同的方式是<a>
标签中的url。
所以你需要对这个URL做出请求
request(details.details, function(err, res, html) { /* code */ })
然后使用cheerio来提取数据。