Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang_asynctask
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8fc440da
authored
Oct 11, 2024
by
gongyang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改方法不正确
parent
03c3dca6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
25 deletions
cmd/bigtv/sync_bigtv_statistics/main.go
cmd/bigtv/sync_bigtv_statistics/main.go
View file @
8fc440da
...
...
@@ -6,7 +6,6 @@ import (
"fmt"
"golang-asynctask/app/dao/scm_data_dao"
"io/ioutil"
"mime/multipart"
"net/http"
"runtime"
"strconv"
...
...
@@ -245,40 +244,28 @@ func RequestUrl(url string) string {
func
PostTopSearchUrl
()
string
{
url
:=
"https://icso.ichunt.com/search/SearchLog/aggs"
method
:=
"POST"
payload
:=
&
bytes
.
Buffer
{}
writer
:=
multipart
.
NewWriter
(
payload
)
_
=
writer
.
WriteField
(
"start_time"
,
strconv
.
FormatInt
(
timeStart
.
Unix
(),
10
))
_
=
writer
.
WriteField
(
"end_time"
,
strconv
.
FormatInt
(
currentUnix
,
10
))
_
=
writer
.
WriteField
(
"no_rule"
,
"1122"
)
_
=
writer
.
WriteField
(
"limit"
,
"200"
)
err
:=
writer
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
""
}
client
:=
&
http
.
Client
{}
req
,
err
:=
http
.
NewRequest
(
method
,
url
,
payload
)
// 要发送的数据
data
:=
`{"start_time":"`
+
strconv
.
FormatInt
(
timeStart
.
Unix
(),
10
)
+
`", "end_time":"`
+
strconv
.
FormatInt
(
currentUnix
,
10
)
+
`", "no_rule":"1122", "limit":"200"}`
// 将数据转换为字节切片
payload
:=
bytes
.
NewBufferString
(
data
)
// 发送POST请求
resp
,
err
:=
http
.
Post
(
url
,
"application/json"
,
payload
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
""
}
req
.
Header
.
Set
(
"Content-Type"
,
writer
.
FormDataContentType
())
res
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
""
}
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
defer
res
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
// 读取响应体
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
""
}
// 打印响应内容
return
string
(
body
)
}
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