김동근

first Commit

const getCardId=require('./getCardId')
const puppeteer=require('puppeteer')
const request = require('request')
const cheerio=require('cheerio')
const fs=require('fs')
const ejs=require('ejs')
......@@ -36,13 +37,21 @@ exports.GetResult=(req,res)=>{
for(let i=1;i<cardIds.length ;i++){
idInQuery+= '%2C'+cardIds[i].cardId
}
//var url = 'https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=' + idInQuery
/*request(url, function(err, res, html){
if(!err){
return cheerio.load(html)
}
})*/
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'})
//idInQuery = '180%2C48886%2C904%2C461'
await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'load'})
const content=await page.content()
browser.close()
return content
......@@ -60,7 +69,7 @@ exports.GetResult=(req,res)=>{
const GetDeckHref=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
let deck=$('#decks-container > main > div.deck-list-wrapper > section > ul > li:nth-child(2) > a')
const deckHref=$(deck).attr('href')
console.log(deckHref)
resolve(deckHref)
......
......@@ -7,7 +7,8 @@ const charset=require('charset')
exports.Crawl=(deckCode)=>{
return new Promise((resolve,reject)=>{
request({
url:`https://deck.codes/${deckCode}`,
//url:`https://deck.codes/${deckCode}`,
url:`https://hs.protolambda.com//${deckCode}`,
encoding:null,
method:'GET',
timeout:10000,
......
......@@ -5,7 +5,7 @@ const pool=mysql.createPool({
host:process.env.DB_HOST,
user:process.env.DB_USER,
password:process.env.DB_PASSWORD,
database:'WhoAreYou',
database:'dapenda',
port:process.env.DB_PORT
})
......
This diff is collapsed. Click to expand it.
......@@ -17,17 +17,18 @@
"body-parser": "^1.18.3",
"charset": "^1.0.1",
"cheerio": "^1.0.0-rc.2",
"dotenv": "^6.1.0",
"dotenv": "^6.2.0",
"ejs": "^2.6.1",
"express": "^4.16.4",
"express": "^4.17.0",
"express-session": "^1.15.6",
"fs": "0.0.1-security",
"iconv-lite": "^0.4.24",
"jquery": "^3.4.1",
"morgan": "^1.9.1",
"mysql": "^2.16.0",
"mysql": "^2.17.1",
"mysql-apostrophe": "^1.0.8",
"path": "^0.12.7",
"puppeteer": "^1.11.0",
"puppeteer": "^1.17.0",
"request": "^2.88.0",
"request-promise": "^4.2.2"
}
......
......@@ -87,17 +87,17 @@
<br>
<div class="row" style="text-align: center;">
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/c/c5/Garrosh_Hellscream%28635%29.png?version=bab934001bb784a94c59a47823d535a7" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/c/c5/Garrosh_Hellscream%28635%29.png?version=1b614ad5340f67612d99542b05168969" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="WARRIOR"/>전사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/4/4b/Thrall%28319%29.png?version=adcee55715548b949a7d973c2fddbd95" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/4/4b/Thrall%28319%29.png?version=d0a09d4b1a9973cf5d3853798915d1ac" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="SHAMAN"/>주술사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/a/a4/Valeera_Sanguinar%282%29.png?version=84a816910b223169eb14cc93c20437b2" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/a/a4/Valeera_Sanguinar%282%29.png?version=8e1f8248cfd10cd0780944f5adae3c88" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="ROGUE"/>도적
</div>
......@@ -107,17 +107,17 @@
<br>
<div class="row" style="text-align: center;">
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/4/4d/Uther_Lightbringer%28257%29.png?version=b45ade5ac3fdd2579160fe5d7b7c1b20" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/4/4d/Uther_Lightbringer%28257%29.png?version=6dfe616bf25bb33225417253ae47a6d8" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="PALADIN"/>성기사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/a/a0/Rexxar%28484%29.png?version=c21b57837db15d20cc814f2bf45682b6" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/a/a0/Rexxar%28484%29.png?version=f018fc6e46b383cc12aefb4b51a66206" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="HUNTER"/>사냥꾼
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/f/fa/Malfurion_Stormrage%28621%29.png?version=b3f5a40e33f33d32995f3becbdd7aa94" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/f/fa/Malfurion_Stormrage%28621%29.png?version=77c0505d00ce8f853911fe2926f85271" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="DRUID"/>드루이드
</div>
......@@ -127,17 +127,17 @@
<br>
<div class="row" style="text-align: center;">
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/0/0a/Gul%27dan%28618%29.png?version=90f421585c6f2d493ba94e259a76190e" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/0/0a/Gul%27dan%28618%29.png?version=cdc516499d50f4887dc32d5a57674c2d" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="WARLOCK"/>흑마법사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/3/3c/Jaina_Proudmoore%28320%29.png?version=75868a59a53f90bce829edeb66126b73" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/3/3c/Jaina_Proudmoore%28320%29.png?version=3b2fe59be9088a51fc77e579e4faa8ce" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="MAGE"/>마법사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/8/80/Anduin_Wrynn%28110%29.png?version=ba8ecc39b3fdd4a2ede72e046c434454" style="width:150px;height:200px;"/>
<img src="https://gamepedia.cursecdn.com/hearthstone_gamepedia/8/80/Anduin_Wrynn%28110%29.png?version=0bac7e0db29ce55f333afe972a0afdb0" style="width:200px;height:250px;"/>
<br>
<input type="radio" name="checkOpponent" value="PRIEST"/>사제
</div>
......
......@@ -89,7 +89,7 @@
</div>
<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 -->
<script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
</body>
......
-- MySQL dump 10.13 Distrib 8.0.13, for Win64 (x86_64)
--
-- Host: localhost Database: whoareyou
-- ------------------------------------------------------
-- Server version 8.0.13
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
SET NAMES utf8mb4 ;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `card`
--
DROP TABLE IF EXISTS `card`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `card` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deckId` int(11) DEFAULT NULL,
`cardId` int(64) DEFAULT NULL,
`cardCost` int(11) DEFAULT NULL,
`cardName` varchar(45) DEFAULT NULL,
`cardNum` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=677 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `card`
--
LOCK TABLES `card` WRITE;
/*!40000 ALTER TABLE `card` DISABLE KEYS */;
INSERT INTO `card` VALUES (626,124,70,1,'Blessing of Might',2),(627,124,41323,1,'Fire Fly',2),(628,124,48982,1,'Glow-Tron',2),(629,124,41912,1,'Lost in the Jungle',2),(630,124,48886,1,'Mecharoo',2),(631,124,42467,1,'Righteous Protector',2),(632,124,679,3,'Divine Favor',2),(633,124,1401,3,'Raid Leader',2),(634,124,45782,3,'Unidentified Maul',2),(635,124,46461,3,'Void Ripper',2),(636,124,45265,5,'Fungalmancer',2),(637,124,559,5,'Leeroy Jenkins',1),(638,124,45877,5,'Level Up!',2),(639,124,43515,7,'Corridor Creeper',2),(640,124,41859,7,'Vinecleaver',2),(641,124,48158,9,'Baku the Mooneater',1),(642,125,70,1,'Blessing of Might',2),(643,125,41323,1,'Fire Fly',2),(644,125,48982,1,'Glow-Tron',2),(645,125,41912,1,'Lost in the Jungle',2),(646,125,48886,1,'Mecharoo',2),(647,125,42467,1,'Righteous Protector',2),(648,125,679,3,'Divine Favor',2),(649,125,1401,3,'Raid Leader',2),(650,125,45782,3,'Unidentified Maul',2),(651,125,46461,3,'Void Ripper',2),(652,125,45265,5,'Fungalmancer',2),(653,125,559,5,'Leeroy Jenkins',1),(654,125,45877,5,'Level Up!',2),(655,125,43515,7,'Corridor Creeper',2),(656,125,41859,7,'Vinecleaver',2),(657,125,48158,9,'Baku the Mooneater',1),(658,126,180,0,'Backstab',2),(659,126,365,0,'Shadowstep',2),(660,126,268,1,'Cold Blood',2),(661,126,41323,1,'Fire Fly',2),(662,126,45340,2,'Prince Keleseth',1),(663,126,306,3,'Edwin VanCleef',1),(664,126,41683,3,'Gluttonous Ooze',1),(665,126,47014,3,'Hench-Clan Thug',2),(666,126,1117,3,'SI:7 Agent',2),(667,126,41418,3,'Tar Creeper',1),(668,126,45531,4,'Elven Minstrel',2),(669,126,43228,4,'Fal\'dorei Strider',2),(670,126,42395,4,'Saronite Chain Gang',2),(671,126,49972,4,'Spirit of the Shark',1),(672,126,45265,5,'Fungalmancer',2),(673,126,559,5,'Leeroy Jenkins',1),(674,126,48487,5,'Myra\'s Unstable Element',1),(675,126,41217,5,'Vilespine Slayer',2),(676,126,49184,5,'Zilliax',1);
/*!40000 ALTER TABLE `card` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `deck`
--
DROP TABLE IF EXISTS `deck`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `deck` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`deckOwner` varchar(45) DEFAULT NULL,
`deckTitle` varchar(45) DEFAULT NULL,
`deckCode` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=127 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `deck`
--
LOCK TABLES `deck` WRITE;
/*!40000 ALTER TABLE `deck` DISABLE KEYS */;
INSERT INTO `deck` VALUES (124,'test','홀수 성기사','AAECAZ8FAq8EnvgCDkbrwgLW/gK4xwL2/QLjywKnBfkK1uUC/eoC0eECteYC+9MCg8cCAA=='),(125,'oss','홀수 성기사','AAECAZ8FAq8EnvgCDkbrwgLW/gK4xwL2/QLjywKnBfkK1uUC/eoC0eECteYC+9MCg8cCAA=='),(126,'oss','켈레서스 템포 토적','AAECAaIHCJziArIC08UCysMCtIYDrwTn+gKggAMLtAHtAowC68ICpu8C3Qjb4wLc0QKbywLR4QKBwgIA');
/*!40000 ALTER TABLE `deck` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` varchar(45) DEFAULT NULL,
`password` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (26,'test','$2a$10$l6IgaLy13XZ7gu3prxvwF.zFH5kfkZVw2AQ6eSZgIeyPjVL3w1fr.'),(27,'oss','$2a$10$79hOQPJMKrTaLo.wk72uReH3SdR2wj4NV2DmWROHZ05uUxgmsP28K');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-05-24 18:28:39