Advertisement
den4ik2003

Untitled

Jul 29th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 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{"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.  
  41. time.Sleep(time.Second)
  42.  
  43. t, _ := driver.FindElement(selenium.ByCSSSelector, "input[name='username']")
  44. _ = t.SendKeys("EaLk5wcx")
  45.  
  46. t, _ = driver.FindElement(selenium.ByCSSSelector, "input[name='password']")
  47. _ = t.SendKeys("EaLk5wcx")
  48.  
  49. t, _ = driver.FindElement(selenium.ByCSSSelector, "button[type='submit']")
  50. _ = t.Click()
  51.  
  52. time.Sleep(time.Hour)
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement