You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: custom-launch.md
+18-1
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,22 @@ Here are the available flags: [link](https://peter.sh/experiments/chromium-comma
108
108
109
109
Read the API doc for more info: [link](https://pkg.go.dev/github.com/go-rod/rod/lib/launcher#Launcher).
110
110
111
+
## Cleanup
112
+
113
+
By default, the browser will create a [user-data-dir](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md)
114
+
to store the user data, such as cookies, cache, etc.
115
+
Rod provides a helper function `Cleanup` to remove it after the browser is fully closed:
116
+
117
+
```go
118
+
funcmain() {
119
+
l:= launcher.New().
120
+
Headless(false).
121
+
Devtools(true)
122
+
123
+
defer l.Cleanup()
124
+
}
125
+
```
126
+
111
127
## Remotely manage the launcher :id=remotely-manage-the-launcher
112
128
113
129
For production scraping system, usually, we will separate the scrapers and browsers into different clusters so that
@@ -124,7 +140,8 @@ Here's an example to use it:
124
140
2. Open another terminal and run code like this [example](https://github.com/go-rod/rod/blob/main/lib/examples/launch-managed/main.go)
125
141
126
142
The image is [tuned](https://github.com/go-rod/rod/blob/main/lib/docker/Dockerfile) for screenshots and fonts among popular natural languages.
127
-
Each container can launch multiple browsers at the same time.
143
+
Each container can launch multiple browsers at the same time. The manager will automatically remove the [user-data-dir](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md)
0 commit comments