web_fuzz.go 610 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package getter
  2. import (
  3. "io/ioutil"
  4. "net/http"
  5. "sync"
  6. "github.com/zu1k/proxypool/proxy"
  7. )
  8. type WebFuzz struct {
  9. Url string
  10. }
  11. func (w WebFuzz) Get() []proxy.Proxy {
  12. resp, err := http.Get(w.Url)
  13. if err != nil {
  14. return nil
  15. }
  16. defer resp.Body.Close()
  17. body, err := ioutil.ReadAll(resp.Body)
  18. if err != nil {
  19. return nil
  20. }
  21. return FuzzParseProxyFromString(string(body))
  22. }
  23. func (w WebFuzz) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) {
  24. wg.Add(1)
  25. nodes := w.Get()
  26. for _, node := range nodes {
  27. pc <- node
  28. }
  29. wg.Done()
  30. }
  31. func NewWebFuzz(url string) *WebFuzz {
  32. return &WebFuzz{Url: url}
  33. }