Absolutely. I’ll turn the entire file into detailed, structured study notes, keeping the important technical concepts, architecture, tools, and implementation tasks while removing repetition.
Web Crawler & Browser Automation in Go — Detailed Notes
1. Why Go for Web Crawling & Browser Automation?
Go is well-suited for high-throughput crawling and automation because of:
-
Goroutines → lightweight concurrency.
-
Low memory overhead → can run many concurrent workers.
-
Strong standard library → especially
net/http,context, concurrency primitives, etc. -
Good support for:
- HTTP clients
- browser automation
- concurrency
- Redis/PostgreSQL
- distributed workers
The overall architecture can be thought of as:
Task Dispatcher
|
+------------+------------+
| |
v v
Fast HTTP Pipeline Stealth Browser Pipeline
| |
net/http / Colly Go-Rod / Playwright
HTML extraction Browser automation
Cookie sessions Human-like interaction
2. Technology Stack
The document divides the stack into "Good Enough" and "State-of-the-Art" approaches.
| Component | Good Enough | Advanced / Stealth |
|---|---|---|
| HTTP | net/http, Colly | tls-client + utls |
| Browser | chromedp | Go-Rod + stealth |
| Parsing | goquery | Vision APIs + goquery fallback |
| Concurrency | Goroutines + worker pools | Rate-limited workers + backoff |
| Storage | Redis + PostgreSQL | Encrypted cookie/session storage + persistent profiles |
Important libraries
Colly
-
High-level Go crawling framework.
-
Handles:
- concurrency
- URL depth
- domain restrictions
- callbacks
- HTML parsing
goquery
- jQuery-style DOM manipulation/parsing.
- Useful when you already have HTML and simply need to extract information.
Go-Rod
-
Browser automation library based around Chrome DevTools Protocol.
-
Useful for:
- clicking
- typing
- navigation
- browser contexts
- dynamic websites.
Playwright-Go
- Go bindings for Playwright.
- Provides browser automation through a higher-level API.
Redis
-
Useful for:
- session storage
- URL frontier
- job queues
- deduplication.
PostgreSQL
- Persistent structured storage.
3. Two Major Crawling Pipelines
The architecture separates crawling into two main paths.
A. Fast HTTP Pipeline
Used when a browser is unnecessary.
Typical stack:
Colly / net/http
↓
HTTP request
↓
HTML
↓
goquery
↓
Extract data
Advantages:
- Much faster.
- Lower memory usage.
- Can run many requests concurrently.
- No browser startup overhead.
Suitable for:
- Static websites.
- Public APIs.
- Pages where JavaScript isn't required.
B. Browser Automation Pipeline
Used when the website requires browser behavior.
Typical stack:
Go-Rod / Playwright
↓
Browser
↓
JavaScript execution
↓
DOM / network responses
↓
Extract data / interact with page
Useful when:
- JavaScript renders content.
- Forms need interaction.
- Authentication is required.
- The website depends on browser state.
The document also describes advanced browser setups involving stealth tooling and human-like interaction.
4. Four Types of Automation
The document divides the problem into four scenarios.
1. Unauthenticated Crawler
No login is required.
Basic approach
Use:
Colly
Colly handles:
- concurrent requests
- URL traversal
- domain restrictions
- parsing callbacks.
Advanced approach
Use a specialized HTTP client capable of controlling TLS/network fingerprints.
The document specifically mentions:
bogdanfinn/tls-client
with utls.
The goal described is to make HTTP traffic resemble browser traffic at the TLS/HTTP protocol level.
5. Authenticated Crawler
Here the crawler must maintain login state.
Basic approach
Use Go's:
http.CookieJar
Flow:
Login
↓
Cookies
↓
CookieJar
↓
Serialize
↓
Redis
↓
Reuse cookies
A browser can also be used initially to perform login and obtain the required session state.
Advanced approach
Persist more than cookies.
Possible browser state includes:
- Cookies
localStorageIndexedDB- Persistent browser profiles.
The document suggests storing browser storage state and restoring it when creating browser contexts.
This avoids repeatedly performing the entire login flow.
6. Unauthenticated Form Filler
Here there is no login, but the automation must interact with forms.
Basic approach
Use:
chromedprod
Typical operations:
Find element
↓
Fill input
↓
Click
↓
Submit
Examples include:
Input()
Click()
Advanced approach
The document describes adding human-like interaction patterns, including:
Mouse movement
Instead of:
A ───────────────→ B
generate a curved trajectory:
A
\__
\___
B
The document suggests Bezier curves.
Typing
Instead of entering characters instantly:
hello
simulate variable delays between keystrokes.
The document gives an example range of roughly:
50ms – 180ms
7. Authenticated Form Filler
This combines:
- Authentication
- Session persistence
- Browser automation
- Form submission
Basic architecture:
Authenticate
↓
Save session
↓
Restore session
↓
Open form
↓
Fill form
↓
Submit
The document also discusses combining fast HTTP/session warm-up with browser automation and external CAPTCHA-solving services.
8. Core Go Architecture
Worker Pool
One of the central ideas is an asynchronous worker pool.
Instead of:
Task 1 → finish
Task 2 → finish
Task 3 → finish
use:
Task Queue
|
+-----------+-----------+
| | |
Worker 1 Worker 2 Worker 3
| | |
Task A Task B Task C
Go makes this natural through:
- Goroutines
- Channels
sync.WaitGroup
Important concepts
Goroutine
Lightweight concurrent execution unit.
Channel
Used to communicate tasks/results between goroutines.
WaitGroup
Used to wait until a collection of goroutines completes.
9. Rate Limiting
Unlimited concurrency is dangerous because it can:
- overload the target
- consume resources
- cause request failures.
The document proposes:
golang.org/x/time/rate
for global rate limiting.
Architecture:
Tasks
↓
Rate Limiter
↓
Worker Pool
↓
HTTP requests
It also mentions contextual backoff, meaning the crawler can slow down when conditions indicate it should.
10. Redis Frontier
A crawler needs to track URLs.
Example:
URL Queue
https://example.com
https://example.com/products
https://example.com/about
Redis can act as the crawler's frontier.
It can store:
- Pending URLs
- Visited URLs
- Form jobs
- Deduplication information.
The document mentions using a Bloom Filter for URL deduplication.
Bloom Filter
A probabilistic data structure used to efficiently answer:
"Have I probably seen this URL before?"
Advantages:
- Memory efficient.
- Very fast.
Important limitation:
It can have false positives.
Meaning it may say:
"Already seen"
when the item wasn't actually seen.
11. Proxy Rotation
A proxy middleware can sit between the crawler and the target.
Worker
↓
Proxy Middleware
↓
Proxy
↓
Website
The document proposes wrapping Go's http.Transport to rotate proxies and handle authentication.
12. Session & Authentication Engine
Session Store
Authentication state can be stored in:
- Redis
- PostgreSQL.
Example:
Browser/Login
↓
Cookies / tokens
↓
Serialize
↓
Redis
Libraries mentioned:
go-redis/v9
jackc/pgx
13. MFA / 2FA
The document describes automating MFA using:
pquerna/otp
for TOTP.
TOTP
Time-based One-Time Password.
Conceptually:
Secret Key + Current Time
↓
TOTP
↓
6-digit code
The document also mentions email/SMS webhooks as another possible mechanism.
14. Session Validation
Sessions can expire.
Therefore, the system should periodically check:
Is session still valid?
A Session Validator Worker can make lightweight HTTP requests.
Flow:
Stored Session
↓
Validation Request
↓
Valid? ── Yes → Keep
|
No
↓
Re-authenticate
15. Browser Instance Pool
Launching a browser for every task is expensive.
Instead:
Browser 1
├── Context A
├── Context B
└── Context C
Browser 2
├── Context D
├── Context E
└── Context F
The document proposes reusable browser pools.
For Go-Rod:
rod.Pool
For Playwright:
Browser Instance Pool
+
BrowserContext Pool
This reduces resource consumption.
16. Browser Context vs Browser
This is an important concept.
Browser
The actual browser process.
Browser Context
An isolated environment inside the browser.
A context can have its own:
- cookies
- storage
- proxy configuration
- session.
So:
One Browser
|
+── Context A → User A
+── Context B → User B
+── Context C → User C
This allows many isolated sessions without launching a separate browser process for every user.
17. Form Interaction Engine
The automation engine should support:
- Text inputs
- Dropdowns
- Checkboxes
- File uploads
- Shadow DOM
- Dynamic elements.
Go-Rod/Playwright can provide the browser-level interaction while DOM tools such as goquery can assist with parsing.
18. Submission Verification
Clicking Submit doesn't necessarily mean the operation succeeded.
A robust system should verify success.
Possible signals:
Network response
Listen for:
XHR
Fetch
HTTP 200 response
DOM changes
Check whether:
Success message appears
or:
Error message appears
The document proposes using CDP events with Go-Rod and ExpectResponse() with Playwright.
19. Stealth / Anti-Detection Architecture
The document distinguishes between ordinary browser automation and more advanced setups intended to reduce automated-browser detection.
The proposed components include:
TLS-level behavior
tls-client
utls
Browser-level behavior
Go-Rod
Playwright
stealth packages
patched browser binaries
Human-like behavior
Mouse movement
Typing
Scrolling
Hovering
Environment consistency
Proxy location
Timezone
Locale
Geolocation
20. Human Dynamics
The document proposes a dedicated package for human-like browser interaction.
Mouse
Generate trajectories using:
Bezier interpolation
instead of straight-line movement.
Keyboard
Use variable delays between key presses.
The document mentions distributions such as:
Gaussian/randomized timing
Scrolling
Instead of instantly jumping to a position:
window.scrollTo(...)
simulate gradual wheel scrolling.
Hover
Occasionally hover over elements.
21. Playwright for Go
The second half of the document proposes Playwright for Go as a unified framework.
Main package:
github.com/playwright-community/playwright-go
One advantage is that the same framework can handle all four scenarios:
- Unauthenticated crawler
- Authenticated crawler
- Unauthenticated form filler
- Authenticated form filler
22. Playwright Browser Contexts
This is one of the most important Playwright concepts.
You can have:
Shared Browser
|
+── Context A
+── Context B
+── Context C
+── Context D
Each context can have its own:
- Cookies
- Proxy
- Headers
- Storage
- Session.
Therefore, thousands of isolated sessions can potentially be managed over a smaller pool of browser instances.
23. Playwright — Four Modes
Mode 1: Unauthenticated Crawler
Basic
Headless Chromium
↓
Block unnecessary assets
↓
Extract DOM/API responses
Playwright's:
page.Route()
can intercept requests.
Mode 2: Authenticated Crawler
Basic flow:
Login
↓
context.StorageState()
↓
Save state
↓
Create new context
↓
Load StorageState
This allows session reuse.
Mode 3: Unauthenticated Form Filler
Use:
page.Locator()
then:
Fill()
Click()
Mode 4: Authenticated Form Filler
Combine:
StorageState
+
multi-page navigation
+
submission monitoring
24. Asset Blocking
One major crawling optimization is to avoid downloading unnecessary resources.
For example:
Images
CSS
Fonts
SVGs
Tracking resources
can often be blocked when you're only interested in data.
Conceptually:
Browser
|
+── HTML → ALLOW
+── API → ALLOW
+── Images → BLOCK
+── CSS → BLOCK
+── Fonts → BLOCK
This can significantly reduce bandwidth and page-loading time.
25. Playwright Session Persistence
Playwright provides:
context.StorageState()
which can save browser storage state.
That state can then be loaded into another context.
Conceptually:
Context A
↓
StorageState JSON
↓
Redis / Disk
↓
Context B
This allows authentication state to survive across browser sessions.
26. Playwright Locators
The document recommends a resilient locator strategy.
Preferred:
GetByRole()
GetByLabel()
GetByPlaceholder()
Fallback:
CSS
XPath
Why?
Because semantic locators are generally less coupled to the exact DOM structure than deeply nested CSS/XPath selectors.
27. Standard .Fill() vs Humanized Typing
Normal automation:
locator.Fill("hello")
sets the value quickly.
The document proposes humanized typing where:
Click input
↓
Wait
↓
Type character
↓
Random delay
↓
Type next character
For example:
60ms
120ms
85ms
170ms
...
rather than perfectly constant timing.
28. Stealth Browser Concepts
The document discusses several browser-detection signals.
Examples mentioned include:
navigator.webdriver- CDP runtime signals
- WebGL fingerprint
- Canvas fingerprint
- Browser plugins
- Permissions.
The proposed advanced setup uses patched/external browser binaries and initialization scripts intended to alter detectable browser characteristics.
29. Proxy + Location Consistency
The document proposes an Egress & Timezone Harmonizer.
The idea is that these browser settings should be consistent with the network egress location:
Proxy IP
↓
Region
↓
Timezone
Locale
Geolocation
Playwright's browser context options can configure these properties.
30. Complete Implementation Roadmap
Phase 1 — Core Architecture
Task 1.1
Build worker pool using:
Go channels
sync.WaitGroup
Task 1.2
Integrate:
Colly / net/http
context.Context
x/time/rate
for cancellation and rate limiting.
Task 1.3
Build Redis frontier:
go-redis/v9
Bloom Filter
pending jobs
visited URLs
Task 1.4
Build proxy middleware around:
http.Transport
31. Phase 2 — Authentication
Build:
Session Store
CookieJar
↓
Serialize
↓
Redis/PostgreSQL
MFA
Use:
pquerna/otp
Session Validator
Periodically check whether sessions are still valid.
32. Phase 3 — Browser Automation
Build:
Browser Pool
Use:
rod.Pool
or Playwright browser pooling.
Selector Engine
Support:
- inputs
- dropdowns
- Shadow DOM
- file uploads.
Submission Listener
Listen to:
XHR
Fetch
network responses
and confirm that the operation actually succeeded.
33. Phase 4 — Stealth & Human Mimicry
Components:
TLS fingerprint handling
↓
Browser stealth
↓
Human mouse movement
↓
Human typing
↓
Scrolling
↓
Proxy/location consistency
The document also lists integration with external CAPTCHA-solving services.
34. Playwright Implementation Roadmap
Phase 1 — Engine Infrastructure
Build:
- Go module
- Playwright lifecycle wrapper
- Browser instance pool
- Browser context pool
- Asset interception
- Per-context proxy configuration.
Phase 2 — Authentication
Build:
Auth Handler
↓
StorageState
↓
Redis Session Vault
Then add:
- 2FA/TOTP
- Session refresh
- Re-authentication when session expires.
Phase 3 — Form Automation
Build:
Locator wrapper
Priority:
GetByRole
↓
GetByLabel
↓
GetByPlaceholder
↓
CSS/XPath
Interaction engine
Support:
- dropdowns
- checkboxes
- file uploads
- Shadow DOM.
Submission verification
Use:
ExpectResponse()
+
DOM checks
35. Phase 4 — Advanced Browser Behavior
Build:
Stealth initialization
context.AddInitScript()
or appropriate stealth packages.
Humanized utilities
HumanMove()
HumanType()
HumanScroll()
Environment harmonization
Configure:
Geolocation
TimezoneID
Locale
to match the intended proxy region.
36. Most Important Concepts to Remember
If you're studying this, focus on these concepts first:
1. HTTP crawler vs browser automation
HTTP crawler
→ fast + lightweight
Browser automation
→ handles JavaScript + interaction
2. Worker pools
Task Queue
↓
Multiple Goroutines
for high-throughput crawling.
3. Browser contexts
One Browser
↓
Many isolated contexts
Each context can represent a different session.
4. Session persistence
Login
↓
StorageState / Cookies
↓
Redis
↓
Restore later
5. Rate limiting
Never simply maximize concurrency. Combine:
Concurrency
+
Rate limiting
+
Backoff
6. Asset blocking
Don't download resources you don't need.
7. Submission verification
Don't assume:
Click Submit = Success
Verify using:
Network response
+
DOM state
8. Browser pooling
Reuse browsers and create lightweight contexts instead of launching a browser per task.
9. Locator resilience
Prefer:
Role / Label / Placeholder
before fragile selectors.
10. Separation of responsibilities
A clean architecture separates:
Task Dispatcher
↓
Worker Pool
↓
HTTP / Browser Worker
↓
Session Manager
↓
Interaction Engine
↓
Verification
↓
Storage
One-Line Mental Model
The entire document can be reduced to:
Use Go's concurrency for scale, HTTP clients for fast crawling, Playwright/Go-Rod for browser-dependent tasks, Redis for distributed state/session management, browser contexts for isolated sessions, and verification + rate limiting to make the automation reliable.