Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오윤석
/
maplespec.ga
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
4
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
오윤석
2020-06-04 23:17:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8bede41be486f724c8f49350554c727ce1234ce5
8bede41b
1 parent
aec00a9f
character code 받아오는 api
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
5 deletions
app/node/app.js
app/node/package-lock.json
app/node/package.json
app/node/routes/character.js
app/node/routes/home.js
app/node/routes/index.js
app/node/app.js
View file @
8bede41
...
...
@@ -6,6 +6,6 @@ let routes = require('./routes');
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
app
.
get
(
'/api/
home'
,
routes
.
home
);
app
.
get
(
'/api/
character'
,
routes
.
character
.
getCharacter
);
let
server
=
app
.
listen
(
80
);
\ No newline at end of file
...
...
app/node/package-lock.json
View file @
8bede41
...
...
@@ -84,6 +84,14 @@
"resolved"
:
"https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz"
,
"integrity"
:
"sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"axios"
:
{
"version"
:
"0.19.2"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.19.2.tgz"
,
"integrity"
:
"sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA=="
,
"requires"
:
{
"follow-redirects"
:
"1.5.10"
}
},
"balanced-match"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz"
,
...
...
@@ -444,6 +452,24 @@
"unpipe"
:
"~1.0.0"
}
},
"follow-redirects"
:
{
"version"
:
"1.5.10"
,
"resolved"
:
"https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz"
,
"integrity"
:
"sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ=="
,
"requires"
:
{
"debug"
:
"=3.1.0"
},
"dependencies"
:
{
"debug"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://registry.npmjs.org/debug/-/debug-3.1.0.tgz"
,
"integrity"
:
"sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g=="
,
"requires"
:
{
"ms"
:
"2.0.0"
}
}
}
},
"forwarded"
:
{
"version"
:
"0.1.2"
,
"resolved"
:
"https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz"
,
...
...
app/node/package.json
View file @
8bede41
...
...
@@ -9,6 +9,7 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"axios"
:
"^0.19.2"
,
"express"
:
"^4.17.1"
,
"http"
:
"0.0.1-security"
,
"nodemon"
:
"^2.0.4"
...
...
app/node/routes/character.js
0 → 100644
View file @
8bede41
axios
=
require
(
'axios'
);
const
crwalCharacterCode
=
async
function
(
nickname
)
{
try
{
const
resp
=
await
axios
.
get
(
"https://maplestory.nexon.com/Ranking/World/Total?c="
+
encodeURI
(
nickname
));
const
regex
=
new
RegExp
(
`<dt><a href=\\"\\/Common\\/Character\\/Detail\\/[^\\?]+?\\?p=(.+?)\\"\\s+target=.+?\\/>
${
nickname
}
<\\/a><\\/dt>`
);
const
regexResult
=
regex
.
exec
(
resp
.
data
);
if
(
!
regexResult
)
return
false
;
return
regexResult
[
1
];
}
catch
(
error
)
{
console
.
log
(
error
);
return
false
;
}
}
module
.
exports
=
{
getCharacter
:
async
function
(
req
,
res
)
{
if
(
!
req
.
query
.
nickname
)
{
res
.
status
(
204
).
send
();
return
;
}
const
nickname
=
req
.
query
.
nickname
;
const
characterCode
=
await
crwalCharacterCode
(
req
.
query
.
nickname
);
if
(
!
characterCode
)
{
res
.
status
(
404
).
send
();
return
;
}
console
.
log
(
characterCode
);
res
.
send
({
text
:
characterCode
});
}
};
\ No newline at end of file
app/node/routes/home.js
deleted
100644 → 0
View file @
aec00a9
module
.
exports
=
function
(
req
,
res
)
{
res
.
send
(
'this is home'
);
}
\ No newline at end of file
app/node/routes/index.js
View file @
8bede41
let
routes
=
{};
routes
.
home
=
require
(
'./home
'
);
routes
.
character
=
require
(
'./character
'
);
module
.
exports
=
routes
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment