Commit acf9c7ff authored by 王明明's avatar 王明明

init

parent 6d9edd1c
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
"log" "log"
"net/url" "net/url"
"strconv" "strconv"
"strings"
"sync"
) )
type AkmClient struct { type AkmClient struct {
...@@ -33,14 +35,17 @@ func NewAkmClient() *AkmClient { ...@@ -33,14 +35,17 @@ func NewAkmClient() *AkmClient {
log.Println(err) log.Println(err)
} }
client.SetProxy("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600") client.SetProxy("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600")
//client.SetProxy("http://127.0.0.1:8888")
return &AkmClient{Jar: jar, Client: client} return &AkmClient{Jar: jar, Client: client}
} }
func GetAbck(times int, abck, bm_sz, urlInput string) string { func GetAbck(times int, urlInput string) {
abck, bmsz := GetCookie()
data := url.Values{} data := url.Values{}
data.Set("times", strconv.Itoa(times)) data.Set("times", strconv.Itoa(times))
data.Set("abck", abck) data.Set("abck", abck)
data.Set("bm_sz", abck) data.Set("bm_sz", bmsz)
data.Set("url", urlInput) data.Set("url", urlInput)
//'url': 'https://www.easyjet.com/en/buy/flights?isOneWay=on&pid=www.easyjet.com' //'url': 'https://www.easyjet.com/en/buy/flights?isOneWay=on&pid=www.easyjet.com'
resp, err := http.PostForm("http://127.0.0.1:3033/akm2t", data) resp, err := http.PostForm("http://127.0.0.1:3033/akm2t", data)
...@@ -49,16 +54,27 @@ func GetAbck(times int, abck, bm_sz, urlInput string) string { ...@@ -49,16 +54,27 @@ func GetAbck(times int, abck, bm_sz, urlInput string) string {
log.Println(err) log.Println(err)
} }
res, _ := io.ReadAll(resp.Body) res, _ := io.ReadAll(resp.Body)
fmt.Println(string(res)) sensor_data := "{\"sensor_data\":\"" + string(res) + "\"}"
return "" akmRes, err := akmClient.Client.Post("https://www.easyjet.com/W-rQf1/Hlbd/0lI/xzR/9pRrLiXx/3YOGQtVbp1iLED/HyNpQmYB/ZBc/QIGwxAlM", "application/json", strings.NewReader(sensor_data))
defer akmRes.Body.Close()
akmResBytes, _ := io.ReadAll(akmRes.Body)
fmt.Println(times, string(akmResBytes))
} }
func GetCookie() (string, string) { func GetCookie() (string, string) {
uri, _ := url.Parse("https://www.easyjet.com/en") uri, _ := url.Parse("https://www.easyjet.com/en")
cookies := akmClient.Jar.Cookies(uri) cookies := akmClient.Jar.Cookies(uri)
for i, v := range cookies { abck := ""
fmt.Println(i, v) bmsz := ""
for _, v := range cookies {
if v.Name == "_abck" {
abck = v.Value
}
if v.Name == "bm_sz" {
bmsz = v.Value
}
} }
return "", "" return abck, bmsz
} }
func initAbck(url string) { func initAbck(url string) {
req, err := http.NewRequest(http.MethodGet, url, nil) req, err := http.NewRequest(http.MethodGet, url, nil)
...@@ -80,18 +96,54 @@ func initAbck(url string) { ...@@ -80,18 +96,54 @@ func initAbck(url string) {
} }
resp, err := akmClient.Client.Do(req) resp, err := akmClient.Client.Do(req)
defer resp.Body.Close()
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return return
} }
}
func query() {
req, err := http.NewRequest("GET", "https://www.easyjet.com/ejavailability/api/v66/availability/query?AdditionalSeats=0&AdultSeats=1&ArrivalIata=LGW&ChildSeats=0&DepartureIata=BFS&IncludeAdminFees=true&IncludeFlexiFares=false&IncludeLowestFareSeats=true&IncludePrices=true&Infants=0&IsTransfer=false&LanguageCode=EN&MaxDepartureDate=2023-03-20&MinDepartureDate=2023-03-18", nil)
if err != nil {
panic(err)
}
req.Header = http.Header{
"accept": {"*/*"},
"accept-language": {"de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"},
"user-agent": {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},
http.HeaderOrderKey: {
"accept",
"accept-language",
"user-agent",
},
}
resp, err := akmClient.Client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close() defer resp.Body.Close()
fmt.Println("响应结果", resp.StatusCode)
//readBytes, _ := io.ReadAll(resp.Body)
//fmt.Println(string(readBytes))
log.Println(fmt.Sprintf("status code: %d", resp.StatusCode))
} }
func main() { func run(wg *sync.WaitGroup) {
akmClient = NewAkmClient() akmClient = NewAkmClient()
initAbck("https://www.easyjet.com/en") initAbck("https://www.easyjet.com/en")
println(GetCookie()) GetAbck(0, "https://www.easyjet.com/en/buy/flights?isOneWay=on&pid=www.easyjet.com")
GetAbck(1, "https://www.easyjet.com/en/buy/flights?isOneWay=on&pid=www.easyjet.com")
GetAbck(2, "https://www.easyjet.com/en/buy/flights?isOneWay=on&pid=www.easyjet.com")
query()
wg.Done()
}
func main() {
wg := &sync.WaitGroup{}
for i := 0; i < 10; i++ {
wg.Add(1)
go run(wg)
}
wg.Wait()
} }
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