Colly 提供了 Post 和 PostRaw 方法,它们的参数类型不一样,需要注意。

 

目标地址接受指定的 Content-Type,可以通过设置 request Header。

 

局部代码:

// @author <cnblogs.com/farwish>

c := colly.NewCollector()

c.OnRequest(func(request *colly.Request) {
    request.Headers.Set("Content-Type", "application/x-www-form-urlencoded")
})

c.OnHTML("a", func(element *colly.HTMLElement) {
    //
})

requestData := map[string]string {
    "abc":    "xxx",
}

err := c.Post(url, requestData)
if err != nil {
    log.Fatal(err)
}

 

Refer:在线运行Golang代码

Link:https://www.cnblogs.com/farwish/p/13203147.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2021-10-07
  • 2021-07-10
  • 2022-12-23
  • 2021-07-03
相关资源
相似解决方案