Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io"
- "math/rand"
- "net/http"
- "os"
- "strings"
- "sync"
- "time"
- )
- func path() string {
- var str string
- for i := 0; i < 5; i++ {
- str += fmt.Sprintf("%x", rand.Intn(16))
- }
- return "http://gs.3g.cn/D/" + str + "/w"
- }
- const dir = "pics/"
- func main() {
- var wg sync.WaitGroup
- for{
- wg.Add(100)
- for i:=0; i < 100; i++{
- go func() {
- p := path()
- resp, err := http.Get(p)
- if err != nil {
- fmt.Println("err")
- }
- urll := resp.Request.URL.String()
- if strings.HasPrefix(urll, "http://gs.3g.cn/D/"){
- wg.Done()
- return
- }
- urll = strings.Replace(urll, "&t=image/jpeg&w=100&h=200", "", -1)
- urll = strings.Replace(urll, "&t=image/png&w=100&h=200", "", -1)
- urll = strings.Replace(urll, "&t=application/zip&w=100&h=200", "", -1)
- urll = strings.Replace(urll, "&t=video/mp4&w=100&h=200", "", -1)
- urll = strings.Replace(urll, "/mms/v14/index.html?u=http%3A%2F%2Fgosms.gomocdn.com%2F", "/", -1)
- fmt.Println(urll)
- if strings.HasSuffix(urll,"200"){
- wg.Done()
- return
- }
- picres, _ := http.Get(urll)
- if strings.Contains(urll,"png"){
- pic, _ := os.Create(dir + time.Now().String()+ ".png")
- defer pic.Close()
- io.Copy(pic, picres.Body)
- wg.Done()
- return
- }
- if strings.Contains(urll,"jpg"){
- pic, _ := os.Create(dir + time.Now().String()+ ".jpg")
- defer pic.Close()
- io.Copy(pic, picres.Body)
- wg.Done()
- return
- }
- if strings.Contains(urll,"jpeg"){
- pic, _ := os.Create(dir + time.Now().String()+ ".jpeg")
- defer pic.Close()
- io.Copy(pic, picres.Body)
- wg.Done()
- return
- }
- if strings.Contains(urll,"zip"){
- pic, _ := os.Create(dir + time.Now().String()+ ".zip")
- defer pic.Close()
- io.Copy(pic, picres.Body)
- wg.Done()
- return
- }
- if strings.Contains(urll,"mp4"){
- pic, _ := os.Create(dir + time.Now().String()+ ".mp4")
- defer pic.Close()
- io.Copy(pic, picres.Body)
- wg.Done()
- return
- }
- wg.Done()
- return
- }()
- }
- wg.Wait()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement