kefu/controller/express.go

27 lines
504 B
Go
Raw Permalink Normal View History

2024-12-10 02:50:12 +00:00
package controller
import (
"github.com/anaskhan96/soup"
"github.com/gin-gonic/gin"
"os"
"strings"
)
func GetExpress(c *gin.Context) {
nu := c.Query("nu")
infos := strings.Split("nu", "|")
nu = infos[0]
com := ""
if len(infos) > 1 {
com = infos[1]
}
url := "http://m.kuaidi.com/queryresults.html?com=" + com + "&nu=" + nu
resp, err := soup.Get(url)
if err != nil {
os.Exit(1)
}
doc := soup.HTMLParse(resp)
links := doc.Find("ul", "class", "timeline").HTML()
c.String(200, links)
}