Beispiel #1
0
func main() {
	ss := Str("f**k your mother")

	le := ss.Encode(strings.CP_UTF16_LE)
	for _, ch := range le {
		Printf("%02X ", ch)
	}
	Println()
	Println(strings.Decode(le, strings.CP_UTF16_LE))

	be := ss.Encode(strings.CP_UTF16_BE)
	for _, ch := range be {
		Printf("%02X ", ch)
	}
	Println()
	Println(strings.Decode(be, strings.CP_UTF16_BE))

	session, _ := http.NewSession()
	session.SetProxy("localhost", 6789)
	session.SetTimeout(0.1)

	resp, err2 := session.Get("https://www.google.com/")

	if err, ok := err2.(*http.HttpError); ok {
		Println("timeout", err.Timeout, err)
	}

	if resp != nil {
		Println("resp", len(resp.Content))
	}

	Console.Pause("f**k")
}
Beispiel #2
0
func testNet() {
	session, _ := http.NewSession()

	session.SetProxy("localhost", 6789)

	session.SetHeaders(Dict{
		"Accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
		"Accept-Encoding": "gzip, deflate",
		"Accept-Language": "zh-CN,en-US;q=0.8,en;q=0.5,zh-HK;q=0.3",
		"User-Agent":      "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0",
		// "Content-Type"      : "application/x-www-form-urlencoded",
		"Connection": "keep-alive",
	})

	resp, err := session.Get("http://www.taobao.com/")

	if err != nil {
		Println(err)
		return
	}

	Println(resp.Encoding)
	Println(resp.Header.Get("Content-Type"))

	_ = resp
}
Beispiel #3
0
func do(user, pass String) error {
	// user, pass := acc[0], acc[1]

	for exiting == false {
		session := http.NewSession()
		// session.SetProxy("localhost", 6789)
		session.SetHeaders(Dict{
			"Accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
			"Accept-Encoding": "gzip, deflate",
			"Accept-Language": "zh-CN,en-US;q=0.8,en;q=0.5,zh-HK;q=0.3",
			"User-Agent":      "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:39.0) Gecko/20100101 Firefox/39.0",
			"Content-Type":    "application/x-www-form-urlencoded",
			"Connection":      "keep-alive",
		})

		for exiting == false {
			exp := Try(func() {
				login(session, user, pass)
			})

			if exp == nil {
				break
			}

			Println(exp)
			time.Sleep(time.Second)
		}

		for i := 0; i != 6 && exiting == false; i++ {
			exp := Try(func() {
				openThread(session, user)
			})

			switch exp {
			case nil:
				for i := 0; i != 600 && exiting == false; i++ {
					time.Sleep(time.Second)
				}

			default:
				Println(exp)
				time.Sleep(2 * time.Second)
			}
		}

		Try(func() {
			Println("logout")
			logout(session)
		})
	}

	return nil
}
Beispiel #4
0
func do(user, pass String) error {
	// user, pass := acc[0], acc[1]

	for {
		session, _ := http.NewSession()
		// session.SetProxy("localhost", 6789)
		session.SetHeaders(Dict{
			"Accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
			"Accept-Encoding": "gzip, deflate",
			"Accept-Language": "zh-CN,en-US;q=0.8,en;q=0.5,zh-HK;q=0.3",
			"User-Agent":      "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:39.0) Gecko/20100101 Firefox/39.0",
			"Content-Type":    "application/x-www-form-urlencoded",
			"Connection":      "keep-alive",
		})

		for {
			err := login(session, user, pass)
			if err == nil {
				break
			}

			Println(err)

			time.Sleep(time.Second)
		}

		for i := 0; i != 6; i++ {
			err := openThread(session, user)

			switch err {
			case nil:
				time.Sleep(10 * time.Minute)

			default:
				Println(err)
				time.Sleep(2 * time.Second)
			}
		}

		Println("logout")
		logout(session)
	}
}
Beispiel #5
0
func testNet() {
	session, _ := http.NewSession()

	session.SetProxy("localhost", 6789)

	session.SetHeaders(Dict{
		"Accept":          "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
		"Accept-Encoding": "gzip, deflate",
		"Accept-Language": "zh-CN,en-US;q=0.8,en;q=0.5,zh-HK;q=0.3",
		"User-Agent":      "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:39.0) Gecko/20100101 Firefox/39.0",
		"Content-Type":    "application/x-www-form-urlencoded",
		"Connection":      "keep-alive",
	})

	resp, err := session.Post(
		"http://bbs.saraba1st.com/2b/member.php",
		Dict{
			"params": Dict{
				"mod":         "logging",
				"action":      "login",
				"loginsubmit": "yes",
				"infloat":     "yes",
				"lssubmit":    "yes",
				"inajax":      "1",
			},
			"body": Dict{
				"fastloginfield": "username",
				"quickforward":   "yes",
				"handlekey":      "ls",
			},
			// "encoding": strings.CP_UTF8,
		},
	)

	resp, err = session.Get("http://bbs.saraba1st.com/2b/forum-75-1.html")

	Println(err)

	_ = resp
}