Skip to content

About

Go SDK for AdsCrawl: real-browser rendering, screenshots, structured extraction, remote CDP, and cloud browsers.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

AdsCrawl

Real browsers. Structured extraction. Screenshots and automation.

Go SDK

Turn a URL into rendered HTML, readable Markdown, structured data, or a PNG screenshot. Open remote CDP sessions and manage persistent cloud browsers with the same API as the TypeScript and Python SDKs.

Website · API documentation · Get an API key · 中文

  • Go 1.21+; no runtime dependencies beyond the standard library.
  • context.Context cancellation and deadlines; 90-second default HTTP timeout.
  • Typed request and response models, checked response shapes, redacted API errors.
  • No automatic retries of metered requests or browser creation.

Install

go get github.com/AdsCrawl/adscrawl-go@v0.1.0

Your first request

Create an account, create an API key, and set ADSCRAWL_API_KEY in your server environment.

package main

import (
    "context"
    "fmt"
    "log"

    adscrawl "github.com/AdsCrawl/adscrawl-go"
)

func main() {
    client, err := adscrawl.NewClient(adscrawl.Config{})
    if err != nil { log.Fatal(err) }
    markdown, err := client.Markdown(context.Background(), adscrawl.ContentOptions{
        PageOptions: adscrawl.PageOptions{URL: "https://www.adscrawl.net", WaitUntil: "domcontentloaded"},
    })
    if err != nil { log.Fatal(err) }
    fmt.Println(markdown)
}

See the complete runnable examples for Markdown, screenshots, structured extraction, fingerprints, CDP, and cloud browsers.

Rendered content and screenshots

client.HTML(ctx, options) returns HTML; Markdown returns Markdown; Article returns a structured Article; Screenshot returns PNG bytes. Page options include viewport, locale, cookies, proxy, managed country, fingerprint, server-side TimeoutMS, and navigation WaitUntil. A custom Proxy and CountryCode cannot be combined.

For a complete screenshot program, run go run ./examples/screenshot. The package's ContentOptions keeps the HTTP API's camelCase fields in JSON while giving Go callers typed fields.

Proxy and fingerprint: BrowserScan screenshot

The fingerprint example uses managed GLOBAL routing unless ADSCRAWL_PROXY_SERVER is set. It opens BrowserScan in a real browser with fingerprint settings and writes browserscan.png. You can also render Pixelscan and IPhey and inspect each site's current result; a particular score is not guaranteed.

go run ./examples/fingerprint

For a custom proxy, set ADSCRAWL_PROXY_SERVER and, if needed, both ADSCRAWL_PROXY_USERNAME and ADSCRAWL_PROXY_PASSWORD. The example never combines a custom proxy with managed routing.

Structured extraction

Run the complete extraction example with go run ./examples/extract. It uses an h1 DOM field on https://www.adscrawl.net and prints both the extracted title and missing fields.

client.SPA.Templates(ctx) lists built-in templates. client.SPA.Inspect(ctx, options) suggests fields and schema.

Remote CDP browsers

Run go run ./examples/cdp for a complete create, inspect, and close sequence.

Pass session.CDPBaseURL to a CDP-compatible automation library when you need to navigate, click, or fill forms. It contains a secret; do not log it. GetVersion validates the token URL and does not forward the API key. The CDP example is runnable with only the standard library.

Persistent cloud browsers

Set ADSCRAWL_PROXY_SERVER, then run the complete launch example with go run ./examples/cloud-browser.

Cloud browser API-key starts and launches require an explicit top-level proxy. A stopping response means shutdown is pending; poll Get until stopped. A failed launch may return a cleanup profile ID in *adscrawl.APIError.

Configuration and errors

Pass Config{Timeout: 75 * time.Second} to change the HTTP deadline. Set PageOptions.TimeoutMS to control the remote browser task separately. Use errors.As(err, &apiErr) with var apiErr *adscrawl.APIError to inspect HTTP status, API code, trace ID, and a cleanup profile ID when present.

ADSCRAWL_API_KEY supplies the key by default. The base URL defaults to ADSCRAWL_BASE_URL, then ADSCRAWL_API_URL, then https://api.adscrawl.net. Errors include APIError, TimeoutError, ConnectionError, and ResponseError. The HTTP deadline includes response body reading. Cancelling a request does not prove remote browser work stopped.

Develop and release

go test ./...
go vet ./...

Tests use local fake responses and consume no AdsCrawl credits. Go packages are published by tagging a public Git repository; see RELEASING.md.

License

MIT

About

Go SDK for AdsCrawl: real-browser rendering, screenshots, structured extraction, remote CDP, and cloud browsers.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages