Continue or use colly at work. Whether it is the official website or some articles on the Internet (in fact, 90% of them copy the cases on the official website), they are all in the same format. I didn’t talk about post. I tested it several times and recorded the use of post.
c := () type data struct { Phone string `json:"phone" binding:"required"` } d:=&data{ Phone:"18190897361", } da,err:=(d) if err!=nil{ (err) } (func(response *) { (string()) }) (func(r *) { (r) () ("Content-Type", "application/json;charset=UTF-8") ("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36") }) (func(response *, e error) { (e) }) ("http://www.××××.com:×××/baseDevice/getUserInfo",da) //("http://www.××××.com:×××/baseDevice/getUserInfo")
In fact, there is not much difference. First, prepare the json format data you want to send (now 90% are requested by json format).
type data struct { Phone string `json:"phone" binding:"required"` } d:=&data{ Phone:"18190897361", } da,err:=(d)
Only one phone number is sent here, and the second part is the last one
("http://www.××××.com:×××/baseDevice/getUserInfo",da)
1: This sentence must be written to the end
(“http://www.××××.com:×××/baseDevice/getUserInfo”)
Visit method, click on the source code and you can see that the default is in the get mode. We send post here, so there is no need to write it.
It's that simple - end
This is the article about golang crawler colly sending post requests. For more related golang colly sending post requests, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!