This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
How to setup proxy settings for Chromedriver
Kory Kim edited this page Jan 23, 2019
·
1 revision
package main
import (
"fmt"
"github.com/sclevine/agouti"
"log"
)
func main() {
driver := agouti.ChromeDriver(
agouti.ChromeOptions("args", []string{
"--headless",
"--disable-gpu",
"--no-sandbox",
"--hide-scrollbars",
"blink-settings=imagesEnabled=false",
"--disable-dev-shm-usage",
"--disable-extensions",
},
),
agouti.Debug,
)
proxys := agouti.ProxyConfig{
ProxyType: "pac", //All type -> {direct|manual|pac|autodetect|system}
ProxyAutoconfigURL: "http://127.0.0.1:1080/pac?t=0000&secret=xxx", //This is Your Shadowsocks local pac url
}
capabilities := agouti.NewCapabilities().Browser("chrome").Proxy(proxys).Without("javascriptEnabled")
err := driver.Start()
if err != nil {
log.Printf("Failed to start driver: %v", err)
}
page, err := driver.NewPage(agouti.Desired(capabilities))
if err != nil {
log.Printf("Failed to open page: %v", err)
}
err = page.Navigate("https://www.google.com")
if err != nil {
log.Printf("Failed to navigate: %v", err)
}
html, err := page.HTML()
fmt.Printf (html)
fmt.Printf("\n")
fmt.Printf(page.Title())
fmt.Printf("\n")
}
Shadowsocks local pac url