Skip to content

Commit

Permalink
文档/融媒体三级标签透出
Browse files Browse the repository at this point in the history
主站任务/公众号/微博任务更新接口
  • Loading branch information
谢铁藜 authored and fengyunlong committed Mar 18, 2024
1 parent baa8acf commit f338f9b
Show file tree
Hide file tree
Showing 16 changed files with 559 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"fmt"
"log"

crawler "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/update"
)

/**
* 网站解决方案-主站检测任务更新接口
*/
func main() {
// 构造CrawlerJobUpdateV1Request请求对象
request := update.NewCrawlerJobUpdateV1Request()

url := "https://news.163.com"
request.SetSiteUrl(url)
request.SetJobId(123123)
request.SetSliceStartTime(123123123)
request.SetSiteName("ceshi")

// 实例化一个crawlerClient,入参需要传入易盾内容安全分配的secretId,secretKey
crawlerClient := crawler.NewCrawlerClientWithAccessKey("YOUR_SECRET_ID", "YOUR_SECRET_KEY")

response, err := crawlerClient.CrawlerJobUpdate(request)
if err != nil {
// 处理错误并打印日志
log.Fatal(err)
}

if response.GetCode() == 200 {
// do something
fmt.Printf("res msg:%s", response.GetMsg())
} else {
fmt.Println("error code: ", response.GetCode())
fmt.Println("error msg: ", response.GetMsg())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"log"

crawler "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/update"
)

/**
* 网站解决方案-公众号检测任务更新接口
*/
func main() {
// 构造OfficialAccountsUpdateV1Request请求对象
request := update.NewOfficialAccountsUpdateV1Request()

request.SetOfficialAccountName("123")
request.SetJobId(123123)
request.SetStartTime(123123123)
request.SetWechatAccount("ceshi")

// 实例化一个crawlerClient,入参需要传入易盾内容安全分配的secretId,secretKey
crawlerClient := crawler.NewCrawlerClientWithAccessKey("YOUR_SECRET_ID", "YOUR_SECRET_KEY")

response, err := crawlerClient.OfficialAccountsUpdate(request)
if err != nil {
// 处理错误并打印日志
log.Fatal(err)
}

if response.GetCode() == 200 {
// do something
fmt.Printf("res msg:%s", response.GetMsg())
} else {
fmt.Println("error code: ", response.GetCode())
fmt.Println("error msg: ", response.GetMsg())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"log"

crawler "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/update"
)

/**
* 网站解决方案-微博检测任务更新接口
*/
func main() {
// 构造WeiboUpdateV1Request请求对象
request := update.NewWeiboUpdateV1Request()

request.SetBlogger("123")
request.SetJobId(123123)
request.SetStartTime(123123123)
request.SetUrl("ceshi")

// 实例化一个crawlerClient,入参需要传入易盾内容安全分配的secretId,secretKey
crawlerClient := crawler.NewCrawlerClientWithAccessKey("YOUR_SECRET_ID", "YOUR_SECRET_KEY")

response, err := crawlerClient.WeiboJobUpdate(request)
if err != nil {
// 处理错误并打印日志
log.Fatal(err)
}

if response.GetCode() == 200 {
// do something
fmt.Printf("res msg:%s", response.GetMsg())
} else {
fmt.Println("error code: ", response.GetCode())
fmt.Println("error msg: ", response.GetMsg())
}
}
22 changes: 22 additions & 0 deletions yidun/service/antispam/crawler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/delete"
jobQuery "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/query"
jobSubmit "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/submit"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/update"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/callback"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/query"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/submit"
Expand Down Expand Up @@ -120,3 +121,24 @@ func (c *CrawlerClient) WeiboDelete(req *delete.WeiboDeleteV1Request) (res *dele
err = c.Client.DoExecute(req, res)
return
}

// 网站解决方案-网站检测任务更新
func (c *CrawlerClient) CrawlerJobUpdate(req *update.CrawlerJobUpdateV1Request) (res *update.CrawlerJobUpdateV1Response, err error) {
res = &update.CrawlerJobUpdateV1Response{}
err = c.Client.DoExecute(req, res)
return
}

// 网站解决方案-网站检测任务更新
func (c *CrawlerClient) OfficialAccountsUpdate(req *update.OfficialAccountsUpdateV1Request) (res *update.OfficialAccountsUpdateV1Response, err error) {
res = &update.OfficialAccountsUpdateV1Response{}
err = c.Client.DoExecute(req, res)
return
}

// 网站解决方案-网站检测任务更新
func (c *CrawlerClient) WeiboJobUpdate(req *update.WeiboUpdateV1Request) (res *update.WeiboUpdateV1Response, err error) {
res = &update.WeiboUpdateV1Response{}
err = c.Client.DoExecute(req, res)
return
}
44 changes: 44 additions & 0 deletions yidun/service/antispam/crawler/crawleriface/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package crawleriface

import (
crawler "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/delete"
jobQuery "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/query"
jobSubmit "github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/submit"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v1/update"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/callback"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/query"
"github.com/yidun/yidun-golang-sdk/yidun/service/antispam/crawler/v3/submit"
Expand All @@ -24,6 +26,48 @@ type CrawlerSolutionAPI interface {

// 网站解决方案-网站&公众号任务异常检测结果分页查询接口
JobQuery(req *jobQuery.CrawlerJobCallbackQueryRequest) (res *jobQuery.JobCallbackQueryResponse, err error)

// 网站解决方案-主站检测任务批量提交检测
CrawlerJobBatchSubmit(req *jobSubmit.CrawlerJobBatchSubmitV1Request) (res *jobSubmit.CrawlerJobBatchSubmitV1Response, err error)

// 网站解决方案-公众号检测任务提交检测
OfficialAccountsSubmit(req *jobSubmit.OfficialAccountsSubmitV1Request) (res *jobSubmit.OfficialAccountsSubmitV1Response, err error)

// 网站解决方案-公众号检测任务批量提交检测
OfficialAccountsBatchSubmit(req *jobSubmit.OfficialAccountsBatchSubmitV1Request) (res *jobSubmit.OfficialAccountsBatchSubmitV1Response, err error)

// 网站解决方案-微博检测任务提交检测
WeiboSubmit(req *jobSubmit.WeiboSubmitV1Request) (res *jobSubmit.WeiboSubmitV1Response, err error)

// 网站解决方案-微博检测任务批量提交检测
WeiboBatchSubmit(req *jobSubmit.WeiboBatchSubmitV1Request) (res *jobSubmit.WeiboBatchSubmitV1Response, err error)

// 网站解决方案-主站检测任务批量查询
CrawlerJobBatchQuery(req *jobQuery.CrawlerJobBatchQueryV1Request) (res *jobQuery.CrawlerJobBatchQueryV1Response, err error)

// 网站解决方案-公众号检测任务批量查询
OfficialAccountsBatchQuery(req *jobQuery.OfficialAccountsBatchQueryV1Request) (res *jobQuery.OfficialAccountsBatchQueryV1Response, err error)

// 网站解决方案-微博检测任务批量查询
WeiboBatchQuery(req *jobQuery.WeiboBatchQueryV1Request) (res *jobQuery.WeiboBatchQueryV1Response, err error)

// 网站解决方案-主站检测任务批量删除
CrawlerJobDelete(req *delete.CrawlerJobDeleteV1Request) (res *delete.CrawlerJobDeleteV1Response, err error)

// 网站解决方案-公众号检测任务批量删除
OfficialAccountsDelete(req *delete.OfficialAccountsDeleteV1Request) (res *delete.OfficialAccountsDeleteV1Response, err error)

// 网站解决方案-微博检测任务批量删除
WeiboDelete(req *delete.WeiboDeleteV1Request) (res *delete.WeiboDeleteV1Response, err error)

// 网站解决方案-网站检测任务更新
CrawlerJobUpdate(req *update.CrawlerJobUpdateV1Request) (res *update.CrawlerJobUpdateV1Response, err error)

// 网站解决方案-网站检测任务更新
OfficialAccountsUpdate(req *update.OfficialAccountsUpdateV1Request) (res *update.OfficialAccountsUpdateV1Response, err error)

// 网站解决方案-网站检测任务更新
WeiboJobUpdate(req *update.WeiboUpdateV1Request) (res *update.WeiboUpdateV1Response, err error)
}

var _ CrawlerSolutionAPI = (*crawler.CrawlerClient)(nil)
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package update

import (
"strconv"

"github.com/yidun/yidun-golang-sdk/yidun/core/http"
"github.com/yidun/yidun-golang-sdk/yidun/core/types"
"github.com/yidun/yidun-golang-sdk/yidun/core/validation"
)

// CrawlerJobUpdateV1Request 网站任务检测更新接口v1.0
type CrawlerJobUpdateV1Request struct {
*types.BizPostFormRequest
// jobId
JobId *int64 `json:"jobId,omitempty"`
// 主站url
SiteUrl *string `json:"siteUrl,omitempty"`
// 网站名称
SiteName *string `json:"siteName,omitempty"`
// 循环爬虫时间区间--开始时间
SliceStartTime *int64 `json:"sliceStartTime,omitempty"`
}

// For NewCrawlerJobUpdateV1Request
func NewCrawlerJobUpdateV1Request() *CrawlerJobUpdateV1Request {
var request = &CrawlerJobUpdateV1Request{
BizPostFormRequest: types.NewBizPostFormRequestWithoutBizId(),
}
request.SetProductCode("crawler")
request.SetUriPattern("/v1/crawler/job/update")
request.SetMethod(http.HttpMethodPost)
request.SetVersion("v1.0")
return request
}

// SetJobId sets the jobId field for the CrawlerJobUpdateV1Request struct.
func (r *CrawlerJobUpdateV1Request) SetJobId(jobId int64) {
r.JobId = &jobId
}

// SetSiteUrl sets the siteUrl field for the CrawlerJobUpdateV1Request struct.
func (r *CrawlerJobUpdateV1Request) SetSiteUrl(siteUrl string) {
r.SiteUrl = &siteUrl
}

// SetSiteName sets the siteName field for the CrawlerJobUpdateV1Request struct.
func (r *CrawlerJobUpdateV1Request) SetSiteName(siteName string) {
r.SiteName = &siteName
}

// SetSliceStartTime sets the sliceStartTime field for the CrawlerJobUpdateV1Request struct.
func (r *CrawlerJobUpdateV1Request) SetSliceStartTime(sliceStartTime int64) {
r.SliceStartTime = &sliceStartTime
}

func (c *CrawlerJobUpdateV1Request) GetBusinessCustomSignParams() map[string]string {
data := c.PostFormRequest.GetBusinessCustomSignParams()

if c.JobId != nil {
data["jobId"] = strconv.FormatInt(*c.JobId, 10)
}
if c.SiteUrl != nil {
data["siteUrl"] = *c.SiteUrl
}
if c.SiteName != nil {
data["siteName"] = *c.SiteName
}
if c.SliceStartTime != nil {
data["sliceStartTime"] = strconv.FormatInt(*c.SliceStartTime, 10)
}
return data
}

func (c *CrawlerJobUpdateV1Request) ValidateParam() error {
invalidParams := validation.ErrInvalidParams{Context: "CrawlerJobUpdateV1Request"}
if c.JobId == nil {
invalidParams.Add(validation.NewErrParamRequired("JobId不能为空"))
}

if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package update

import "github.com/yidun/yidun-golang-sdk/yidun/core/types"

// CrawlerJobUpdateV1Response 网站任务更新接口响应对象v1.0
type CrawlerJobUpdateV1Response struct {
*types.CommonResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package update

import (
"strconv"

"github.com/yidun/yidun-golang-sdk/yidun/core/http"
"github.com/yidun/yidun-golang-sdk/yidun/core/types"
"github.com/yidun/yidun-golang-sdk/yidun/core/validation"
)

// OfficialAccountsUpdateV1Request 公众号检测更新接口v1.0
type OfficialAccountsUpdateV1Request struct {
*types.BizPostFormRequest
// @NotNull
JobId *int64 `json:"jobId,omitempty"`
// 微信号
WechatAccount *string `json:"wechatAccount,omitempty"`
// 公众号名称
OfficialAccountName *string `json:"officialAccountName,omitempty"`
// 循环爬虫时间区间--开始时间
StartTime *int64 `json:"startTime,omitempty"`
}

// For OfficialAccountsUpdateV1Request
func NewOfficialAccountsUpdateV1Request() *OfficialAccountsUpdateV1Request {
var request = &OfficialAccountsUpdateV1Request{
BizPostFormRequest: types.NewBizPostFormRequestWithoutBizId(),
}
request.SetProductCode("crawler")
request.SetUriPattern("/v1/official-accounts/job/update")
request.SetMethod(http.HttpMethodPost)
request.SetVersion("v1.0")
return request
}

// SetJobId sets the jobId field for the OfficialAccountsUpdateV1Request struct.
func (r *OfficialAccountsUpdateV1Request) SetJobId(jobId int64) {
r.JobId = &jobId
}

// SetWechatAccount sets the wechatAccount field for the OfficialAccountsUpdateV1Request struct.
func (r *OfficialAccountsUpdateV1Request) SetWechatAccount(wechatAccount string) {
r.WechatAccount = &wechatAccount
}

// SetOfficialAccountName sets the officialAccountName field for the OfficialAccountsUpdateV1Request struct.
func (r *OfficialAccountsUpdateV1Request) SetOfficialAccountName(officialAccountName string) {
r.OfficialAccountName = &officialAccountName
}

// SetStartTime sets the startTime field for the OfficialAccountsUpdateV1Request struct.
func (r *OfficialAccountsUpdateV1Request) SetStartTime(startTime int64) {
r.StartTime = &startTime
}

func (c *OfficialAccountsUpdateV1Request) GetBusinessCustomSignParams() map[string]string {
data := c.PostFormRequest.GetBusinessCustomSignParams()

if c.JobId != nil {
data["jobId"] = strconv.FormatInt(*c.JobId, 10)
}
if c.WechatAccount != nil {
data["wechatAccount"] = *c.WechatAccount
}
if c.OfficialAccountName != nil {
data["officialAccountName"] = *c.OfficialAccountName
}
if c.StartTime != nil {
data["startTime"] = strconv.FormatInt(*c.StartTime, 10)
}
return data
}

func (c *OfficialAccountsUpdateV1Request) ValidateParam() error {
invalidParams := validation.ErrInvalidParams{Context: "OfficialAccountsUpdateV1Request"}
if c.JobId == nil {
invalidParams.Add(validation.NewErrParamRequired("JobId不能为空"))
}

if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}

0 comments on commit f338f9b

Please sign in to comment.