27 lines
504 B
Go
27 lines
504 B
Go
|
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)
|
||
|
}
|