Yuseunggeun

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

Showing 1 changed file with 38 additions and 1 deletions
1 -//2019102201 컴퓨터공학과 유승근
...\ No newline at end of file ...\ No newline at end of file
1 +//2019102201 컴퓨터공학과 유승근
2 +var cheerio = require("cheerio");
3 +var request = require("request");
4 +var express = require("express");
5 +var router = express.Router();
6 +
7 +var url = "https://www.videocardbenchmark.net/gpu_value.html#all-time-value";
8 +var Graphic_card = [];
9 +var Price = [];
10 +var count = 20;
11 +
12 +//그래픽카드 순위 출력 테스트
13 +request(url, function(error, response, html){
14 + if(!error){
15 + var $ = cheerio.load(html);
16 +
17 + for(var i = 0; i < count; i++){
18 + $('ul.chartlist > li > a > span.prdname').each(function(){
19 + var item_name = $(this);
20 + var item_name_text = item_name.text();
21 + Graphic_card[i] = item_name_text;
22 + i++;
23 + })
24 + }
25 + for(var i = 0; i < count; i++){
26 + $('ul.chartlist > li > a > span.price-neww').each(function(){
27 + var price = $(this);
28 + var price_text = price.text();
29 + Price[i] = price_text;
30 + i++;
31 + })
32 + }
33 +
34 + for(var i = 0; i < count; i++){
35 + console.log((i+1) + "."+Graphic_card[i]+" - ("+Price[i]+"$)");
36 + }
37 + }
38 +});
......