Advertisement
Guest User

Untitled

a guest
Nov 21st, 2020
1,243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "io"
  6. "math/rand"
  7. "net/http"
  8. "os"
  9. "strings"
  10. "sync"
  11. "time"
  12. )
  13.  
  14. func path() string {
  15. var str string
  16. for i := 0; i < 5; i++ {
  17. str += fmt.Sprintf("%x", rand.Intn(16))
  18. }
  19. return "http://gs.3g.cn/D/" + str + "/w"
  20. }
  21.  
  22. const dir = "pics/"
  23.  
  24. func main() {
  25. var wg sync.WaitGroup
  26. for{
  27. wg.Add(100)
  28. for i:=0; i < 100; i++{
  29. go func() {
  30. p := path()
  31. resp, err := http.Get(p)
  32. if err != nil {
  33. fmt.Println("err")
  34. }
  35. urll := resp.Request.URL.String()
  36. if strings.HasPrefix(urll, "http://gs.3g.cn/D/"){
  37. wg.Done()
  38. return
  39. }
  40. urll = strings.Replace(urll, "&t=image/jpeg&w=100&h=200", "", -1)
  41. urll = strings.Replace(urll, "&t=image/png&w=100&h=200", "", -1)
  42. urll = strings.Replace(urll, "&t=application/zip&w=100&h=200", "", -1)
  43. urll = strings.Replace(urll, "&t=video/mp4&w=100&h=200", "", -1)
  44.  
  45. urll = strings.Replace(urll, "/mms/v14/index.html?u=http%3A%2F%2Fgosms.gomocdn.com%2F", "/", -1)
  46. fmt.Println(urll)
  47. if strings.HasSuffix(urll,"200"){
  48. wg.Done()
  49. return
  50. }
  51. picres, _ := http.Get(urll)
  52. if strings.Contains(urll,"png"){
  53. pic, _ := os.Create(dir + time.Now().String()+ ".png")
  54. defer pic.Close()
  55. io.Copy(pic, picres.Body)
  56. wg.Done()
  57. return
  58. }
  59. if strings.Contains(urll,"jpg"){
  60. pic, _ := os.Create(dir + time.Now().String()+ ".jpg")
  61. defer pic.Close()
  62. io.Copy(pic, picres.Body)
  63. wg.Done()
  64. return
  65. }
  66. if strings.Contains(urll,"jpeg"){
  67. pic, _ := os.Create(dir + time.Now().String()+ ".jpeg")
  68. defer pic.Close()
  69. io.Copy(pic, picres.Body)
  70. wg.Done()
  71. return
  72. }
  73. if strings.Contains(urll,"zip"){
  74. pic, _ := os.Create(dir + time.Now().String()+ ".zip")
  75. defer pic.Close()
  76. io.Copy(pic, picres.Body)
  77. wg.Done()
  78. return
  79. }
  80. if strings.Contains(urll,"mp4"){
  81. pic, _ := os.Create(dir + time.Now().String()+ ".mp4")
  82. defer pic.Close()
  83. io.Copy(pic, picres.Body)
  84. wg.Done()
  85. return
  86. }
  87. wg.Done()
  88. return
  89. }()
  90. }
  91. wg.Wait()
  92. }
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement