Commit 87247bb9 authored by anqi-wmm's avatar anqi-wmm

生产 sensor_data

测试成功
parent dc15ac30
......@@ -15,6 +15,11 @@ func WelcomeHandler(w http.ResponseWriter, r *http.Request) {
func main() {
logrus.SetLevel(logrus.TraceLevel)
logrus.SetFormatter(&logrus.TextFormatter{
//HideKeys: true,
TimestampFormat: "2006-01-02 15:04:05.000", //时间格式
FullTimestamp: true,
})
//str := "<noscript><img src=\"https://www.easyjet.com/akam/13/pixel_7b9d10f9?a=dD1lMmMzOTBjM2M4NWUyYz\nkzNjljOTNhZDUyNmRkOGJjMDdjNjM2MWJmJmpzPW9mZg==\" style=\"visibility: hidden; position: absolu\nte; left: -999px; top: -999px;\" /></noscript><script type=\"text/javascript\" src=\"/-Hzovq/uluGM/jHPdr/v3N7/m5OOLVXmDOwY/NG4dCQE/Zy/lnEF9qaQI\"></script></body>\n</html>"
//reg, _ := regexp.Compile("</noscript><script type=\"text/javascript\" src=\"(.+?)\"></s")
//matchs := reg.FindStringSubmatch(str)
......
......@@ -62,15 +62,18 @@ func GetAbck(times int, urlInput string) []*http.Cookie {
//}
//res, _ := io.ReadAll(resp.Body)
ua := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50"
res := sensor.GenData(abck, bmsz, ua, urlInput)
t1 := time.Now()
res := sensor.GenData(abck, bmsz, ua, urlInput)
logrus.Info("生产一次 abck 耗时", time.Since(t1).String())
t1 = time.Now()
sensor_data := "{\"sensor_data\":\"" + string(res) + "\"}"
akmRes, err := akmClient.Client.Post("https://www.easyjet.com"+akmClient.SensorUrl, "application/json", strings.NewReader(sensor_data))
if err != nil {
log.Fatalln(err)
}
defer akmRes.Body.Close()
logrus.Info("响应abck结果", akmRes.StatusCode, "请求耗时", time.Since(t1).String())
logrus.Info("第", times, "响应abck结果", akmRes.StatusCode, "请求耗时", time.Since(t1).String())
return akmRes.Cookies()
}
......
......@@ -5,11 +5,13 @@ import (
"github.com/sirupsen/logrus"
"net/http"
"test/util"
"time"
)
func routeToU2(w http.ResponseWriter, r *http.Request) {
t1 := time.Now()
data := util.GetPostJson(r)
logrus.Printf("请求一次", data)
logrus.Info("请求一次", data)
if err := checkPostRequire(data); err == false {
util.WriteJson(w, util.ErrorJson("请求参数不正确"))
}
......@@ -24,6 +26,8 @@ func routeToU2(w http.ResponseWriter, r *http.Request) {
util.WriteJson(w, util.ErrorJson("不支持的航司"))
return
}
logrus.Info("请求结束 耗时", time.Since(t1).String())
cookies := akm.Cookies
util.WriteJson(w, &util.Response{
......
......@@ -2,7 +2,6 @@ package sensor
import (
"fmt"
"github.com/sirupsen/logrus"
"math"
"math/rand"
"net/url"
......@@ -499,9 +498,7 @@ func bd(a, b string) string {
return a + b
}
func GenData(abck, bmsz, ua, url string) string {
t1 := time.Now()
akm := NewAkmSign(0, url, ua, abck, bmsz)
logrus.Info("生产一次 abck 耗时", time.Since(t1).String())
return akm.genData()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment