Toggle navigation
Toggle navigation
This project
Loading...
Sign in
윤준석
/
mamuri-bot
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
윤준석
2022-05-10 03:47:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fa7b2ba3c0fde0108b3350cd3272ce7fd08533ee
fa7b2ba3
1 parent
b97339d7
ADD: sample api request implementation
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
joongna/main.go
joongna/main.go
View file @
fa7b2ba
package
main
import
(
"fmt"
"io/ioutil"
"joongna/config"
"log"
"net/http"
url2
"net/url"
)
func
main
()
{
keyword
:=
"m1 pro 맥북 프로 16인치"
encText
:=
url2
.
QueryEscape
(
"중고나라"
+
keyword
)
url
:=
"https://openapi.naver.com/v1/search/cafearticle.json?query="
+
encText
+
"&sort=sim"
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
req
.
Header
.
Add
(
"X-Naver-Client-Id"
,
config
.
Cfg
.
Secret
.
CLIENTID
)
req
.
Header
.
Add
(
"X-Naver-Client-Secret"
,
config
.
Cfg
.
Secret
.
CLIENTSECRET
)
client
:=
&
http
.
Client
{}
resp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
defer
resp
.
Body
.
Close
()
bytes
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
str
:=
string
(
bytes
)
fmt
.
Println
(
str
)
}
...
...
Please
register
or
login
to post a comment