Advertisement
den4ik2003

Untitled

Jul 29th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "log"
  6. "time"
  7.  
  8. "github.com/tebeka/selenium"
  9. "github.com/tebeka/selenium/chrome"
  10. )
  11.  
  12. func main() {
  13. service, err := selenium.NewChromeDriverService("./chromedriver", 4444)
  14. if err != nil {
  15. log.Fatal("Serivce error")
  16. }
  17. defer service.Stop()
  18.  
  19. proxy := "85.142.44.17:64654"
  20.  
  21. caps := selenium.Capabilities{}
  22. chromeCaps := chrome.Capabilities{
  23. Args: []string{
  24. fmt.Sprintf("--proxy-server=%s", proxy),
  25. },
  26. Extensions: []string{"/home/den4ik/go-exps/extension"}, // Путь к вашему архивированному расширению
  27. }
  28. caps.AddChrome(chromeCaps)
  29.  
  30. driver, err := selenium.NewRemote(caps, "http://127.0.0.1:4444/wd/hub")
  31. if err != nil {
  32. log.Fatalf("Failed to open a session: %v", err)
  33. }
  34. defer driver.Quit()
  35.  
  36. // Пример отправки запроса
  37. if err := driver.Get("https://api.ipify.org"); err != nil {
  38. log.Fatalf("Failed to load page: %v", err)
  39. }
  40. time.Sleep(time.Hour)
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement