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

init

parent 6d9edd1c
......@@ -8,6 +8,8 @@ import (
"log"
"net/url"
"strconv"
"strings"
"sync"
)
type AkmClient struct {
......@@ -33,14 +35,17 @@ func NewAkmClient() *AkmClient {
log.Println(err)
}
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}
}
func GetAbck(times int, abck, bm_sz, urlInput string) string {
func GetAbck(times int, urlInput string) {
abck, bmsz := GetCookie()
data := url.Values{}
data.Set("times", strconv.Itoa(times))
data.Set("abck", abck)
data.Set("bm_sz", abck)
data.Set("bm_sz", bmsz)
data.Set("url", urlInput)
//'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)
......@@ -49,16 +54,27 @@ func GetAbck(times int, abck, bm_sz, urlInput string) string {
log.Println(err)
}
res, _ := io.ReadAll(resp.Body)
fmt.Println(string(res))
return ""
sensor_data := "{\"sensor_data\":\"" + string(res) + "\"}"
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) {
uri, _ := url.Parse("https://www.easyjet.com/en")
cookies := akmClient.Jar.Cookies(uri)
for i, v := range cookies {
fmt.Println(i, v)
abck := ""
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) {
req, err := http.NewRequest(http.MethodGet, url, nil)
......@@ -80,18 +96,54 @@ func initAbck(url string) {
}
resp, err := akmClient.Client.Do(req)
defer resp.Body.Close()
if err != nil {
log.Println(err)
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()
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()
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