Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-06-09 23:23:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a6bbc5178e0f83221dabdf1b59822b7440a632d
8a6bbc51
1 parent
87c91016
Update getBJ function parameter
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
jaksimsamil-server/src/util/getBJ.js
jaksimsamil-server/src/util/getBJ.js
View file @
8a6bbc5
const
axios
=
require
(
"axios"
);
const
cheerio
=
require
(
"cheerio"
);
let
userid_test
=
"syw5141"
;
const
getHtml
=
async
(
userid
)
=>
{
try
{
return
await
axios
.
get
(
"https://www.acmicpc.net/user/"
+
userid
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
getHtml
(
userid_test
).
then
((
html
)
=>
{
let
psList
=
[];
const
$
=
cheerio
.
load
(
html
.
data
);
const
$bodyList
=
$
(
"div.panel-body"
).
children
();
$bodyList
.
each
(
function
(
i
)
{
if
(
i
%
2
==
0
)
{
psList
[
i
/
2
]
=
{
problem_number
:
$
(
this
).
children
().
text
(),
problem_title
:
$
(
this
).
next
().
children
().
text
(),
}
;
exports
.
getBJ
=
function
(
userid
)
{
const
getHtml
=
async
(
userid
)
=>
{
try
{
return
await
axios
.
get
(
"https://www.acmicpc.net/user/"
+
userid
);
}
catch
(
error
)
{
console
.
log
(
error
)
;
}
}
)
;
};
console
.
log
(
psList
);
return
psList
;
});
getHtml
(
userid
).
then
((
html
)
=>
{
let
psList
=
[];
const
$
=
cheerio
.
load
(
html
.
data
);
const
$bodyList
=
$
(
"div.panel-body"
).
children
();
//body > div.wrapper > div.container.content > div.row > div:nth-child(2) > div:nth-child(3) > div.col-md-9 > div:nth-child(1) > div.panel-body
$bodyList
.
each
(
function
(
i
)
{
if
(
i
%
2
==
0
)
{
psList
[
i
/
2
]
=
{
problem_number
:
$
(
this
).
children
().
text
(),
problem_title
:
$
(
this
).
next
().
children
().
text
(),
};
}
});
console
.
log
(
psList
);
return
psList
;
});
};
...
...
Please
register
or
login
to post a comment