Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
search-page
Commits
fae4ae5a
Commit
fae4ae5a
authored
Jan 13, 2021
by
baesangjune
Browse files
머지확인
parent
1921d18c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
fae4ae5a
This diff is collapsed.
Click to expand it.
server/controllers/review.controller.js
View file @
fae4ae5a
...
...
@@ -4,12 +4,12 @@ import jschardet from 'jschardet'
// import iconv from 'iconv'
import
fs
from
'
fs
'
import
axios
from
'
axios
'
;
const
Iconv
=
iconv
.
Iconv
//
const Iconv = iconv.Iconv
const
search
=
async
(
req
,
res
)
=>
{
const
url
=
"
https://www.google.com/search?q=
"
+
encodeURI
(
req
.
params
.
search
)
+
"
+site%3Atistory.com&page_no=1
"
const
editUrl
=
/
(
http
(
s
)?
:
\/\/)([
a-z0-9
\w]
+
\.
*
)
+
[
a-z0-9
]{2,4}
/gi
axios
.
get
(
url
)
axios
.
get
(
url
)
// .then(anyToUtf8)
.
then
((
html
)
=>
{
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
...
...
@@ -23,7 +23,7 @@ const search = async (req, res) => {
reviews
[
i
]
=
{
title
:
$1
(
this
).
find
(
'
h3
'
).
text
(),
link
:
link
,
summary
:
$1
(
this
).
find
(
'
.s3v9rd
'
).
text
(),
summary
:
$1
(
this
).
find
(
'
.s3v9rd
'
).
find
(
'
.s3v9rd
'
).
text
(),
}
})
// reviews.forEach((review, i) => {
...
...
@@ -39,11 +39,11 @@ const search = async (req, res) => {
console
.
log
(
reviews
)
res
.
send
(
reviews
)
})
function
anyToUtf8
(
str
)
{
const
{
encoding
}
=
jschardet
.
detect
(
str
);
// 웹페이지 문서의 인코딩 타입을 확인
const
iconv
=
new
Iconv
(
encoding
,
"
utf-8//translit//ignore
"
);
// euc-kr 인코딩변환
return
iconv
.
convert
(
str
).
toString
();
}
//
function anyToUtf8(str) {
//
const { encoding } = jschardet.detect(str); // 웹페이지 문서의 인코딩 타입을 확인
//
const iconv = new Iconv(encoding, "utf-8//translit//ignore"); // euc-kr 인코딩변환
//
return iconv.convert(str).toString();
//
}
// try {
// const newPlace = await new Place({
// name: req.params.search,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment