Yuseunggeun

modify app.js(그래픽카드 정보 크롤링)

Showing 1 changed file with 38 additions and 1 deletions
//2019102201 컴퓨터공학과 유승근
\ No newline at end of file
//2019102201 컴퓨터공학과 유승근
var cheerio = require("cheerio");
var request = require("request");
var express = require("express");
var router = express.Router();
var url = "https://www.videocardbenchmark.net/gpu_value.html#all-time-value";
var Graphic_card = [];
var Price = [];
var count = 20;
//그래픽카드 순위 출력 테스트
request(url, function(error, response, html){
if(!error){
var $ = cheerio.load(html);
for(var i = 0; i < count; i++){
$('ul.chartlist > li > a > span.prdname').each(function(){
var item_name = $(this);
var item_name_text = item_name.text();
Graphic_card[i] = item_name_text;
i++;
})
}
for(var i = 0; i < count; i++){
$('ul.chartlist > li > a > span.price-neww').each(function(){
var price = $(this);
var price_text = price.text();
Price[i] = price_text;
i++;
})
}
for(var i = 0; i < count; i++){
console.log((i+1) + "."+Graphic_card[i]+" - ("+Price[i]+"$)");
}
}
});
......