Yuseunggeun

modify app.js

Showing 1 changed file with 8 additions and 31 deletions
//2019102201 컴퓨터공학과 유승근
var cheerio = require("cheerio");
var path = require("path");
var request = require("request");
var express = require("express");
var router = express.Router();
var index = require("./routes/index");
var url = "https://www.videocardbenchmark.net/gpu_value.html#all-time-value";
var Graphic_card = [];
var Price = [];
var count = 20;
var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
//그래픽카드 순위 출력 테스트
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]+"$)");
}
}
});
app.use('/',index);
var server = app.listen(3000);
module.exports = app;
\ No newline at end of file
......