Skip to content

Commit d8c3700

Browse files
committed
Stealth browser as option. Update default config
1 parent 7f0f32a commit d8c3700

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

cmd/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
version = "0.3"
15+
version = "0.4.1"
1616
defaultConfigFilename = "config"
1717
envPrefix = "OPENSERP"
1818
)
@@ -42,6 +42,7 @@ type AppConfig struct {
4242
IsRawRequests bool `mapstructure:"raw_requests"`
4343
ProxyURL string `mapstructure:"proxy"`
4444
Insecure bool `mapstructure:"insecure"`
45+
IsStealth bool `mapstructure:"stealth"`
4546
}
4647

4748
var config = Config{}
@@ -136,5 +137,5 @@ func init() {
136137
RootCmd.PersistentFlags().BoolVarP(&config.App.IsLeaveHead, "leave", "", false, "Leave browser and tabs opened after search is made")
137138
RootCmd.PersistentFlags().StringVarP(&config.Config2Capcha.ApiKey, "2captcha_key", "", "", "2 captcha api key")
138139
RootCmd.PersistentFlags().StringVarP(&config.App.ProxyURL, "proxy", "x", "", "HTTP or Socks5 proxy URL (e.g. http://user:[email protected]:8080)")
139-
RootCmd.PersistentFlags().BoolVarP(&config.App.Insecure, "insecure", "k", false, "Allow insecure TLS connections")
140+
RootCmd.PersistentFlags().BoolVarP(&config.App.IsStealth, "stealth", "s", false, "Use stealth browser plugin")
140141
}

cmd/search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func searchBrowser(engineType string, query core.Query) ([]core.SearchResult, er
6363
CaptchaSolverApiKey: config.Config2Capcha.ApiKey,
6464
ProxyURL: config.App.ProxyURL,
6565
Insecure: config.App.Insecure,
66+
UseStealth: config.App.IsStealth,
6667
}
6768

6869
if config.App.IsDebug {

cmd/serve.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func serve(cmd *cobra.Command, args []string) {
8080
CaptchaSolverApiKey: config.Config2Capcha.ApiKey,
8181
ProxyURL: config.App.ProxyURL,
8282
Insecure: config.App.Insecure,
83+
UseStealth: config.App.IsBrowserHead,
8384
}
8485

8586
if config.App.IsDebug {

config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ app:
77
head: false
88
leakless: false
99
leave_head: false
10+
stealth: false
11+
insecure: false
1012

1113
2captcha:
1214
apikey: "123123123123123"

core/browser.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type BrowserOpts struct {
2323
CaptchaSolverApiKey string // 2Captcha api key
2424
ProxyURL string // Proxy URL
2525
Insecure bool // Allow insecure TLS connections
26+
UseStealth bool // Use go-rod stealth plugin
2627

2728
}
2829

@@ -123,7 +124,13 @@ func (b *Browser) Navigate(URL string) (*rod.Page, error) {
123124
b.browser.MustIgnoreCertErrors(true)
124125
}
125126

126-
page := stealth.MustPage(b.browser)
127+
var page *rod.Page
128+
if b.UseStealth {
129+
page = stealth.MustPage(b.browser)
130+
} else {
131+
page = b.browser.MustPage(URL)
132+
}
133+
127134
page.MustEmulate(devices.Device{
128135
AcceptLanguage: b.LanguageCode,
129136
})

0 commit comments

Comments
 (0)