Browser

Scrapfly SDK Go

Try it

Web scraping from Go with the Scrapfly SDK (`github.com/scrapfly/go-scrapfly`). Use when the user asks to scrape a URL, bypass anti-bot protection, render Ja...

What it does

Use the module to scrape web pages from Go with proxy rotation, anti-bot bypass (ASP), JavaScript rendering, screenshots, and AI extraction. It ships a built-in selector for parsing the response.

The skill document

Scrapfly Go SDK

Use the go-scrapfly module to scrape web pages from Go with proxy rotation, anti-bot bypass (ASP), JavaScript rendering, screenshots, and AI extraction. It ships a built-in goquery selector for parsing the response.

When to use

  • Scraping web pages (HTML, JSON, text, markdown) from a Go codebase
  • Bypassing anti-bot protections (Cloudflare, DataDome, PerimeterX, Kasada)
  • Rendering JavaScript-heavy pages with a headless browser
  • Capturing screenshots or extracting structured data

Setup

go get github.com/scrapfly/go-scrapfly
export SCRAPFLY_API_KEY="your-api-key"

The package name is scrapfly. Get your API key at scrapfly.io.

Basic scrape

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/scrapfly/go-scrapfly"
)

func main() {
    client, err := scrapfly.New(os.Getenv("SCRAPFLY_API_KEY"))
    if err != nil {
        log.Fatalf("failed to create client: %v", err)
    }

    apiResponse, err := client.Scrape(&scrapfly.ScrapeConfig{
        URL: "https://web-scraping.dev/product/1",
    })
    if err != nil {
        log.Fatalf("scrape failed: %v", err)
    }

    fmt.Println(apiResponse.Result.Content)
}

Anti-bot bypass, geo-targeting, JS rendering

ScrapeConfig fields are Go-idiomatic PascalCase. ProxyPool takes a typed constant.

apiResponse, err := client.Scrape(&scrapfly.ScrapeConfig{
    URL:             "https://web-scraping.dev/product/1",
    ASP:             true,                            // bypass anti-bot
    Country:         "us",                            // proxy country (ISO 3166-1 alpha-2)
    ProxyPool:       scrapfly.PublicResidentialPool,  // or scrapfly.PublicDataCenterPool
    RenderJS:        true,                            // headless browser rendering
    WaitForSelector: "div.product",                  // requires RenderJS
    RenderingWait:   5000,                            // ms, requires RenderJS
    Format:          "markdown",                      // raw | clean_html | json | markdown | text
})

Built-in HTML selector

selector, err := apiResponse.Selector() // goquery document
if err != nil {
    log.Fatal(err)
}
fmt.Println("Title:", selector.Find("h3").First().Text())

Screenshots and extraction

shot, err := client.Screenshot(&scrapfly.ScreenshotConfig{
    URL: "https://web-scraping.dev/products",
})

data, err := client.Extract(&scrapfly.ExtractionConfig{
    Body:             []byte(apiResponse.Result.Content),
    ContentType:      "text/html",
    ExtractionPrompt: "extract all product names and prices",
})

Important notes

  • RenderJS: true is required for RenderingWait, WaitForSelector, and screenshots
  • scrapfly.PublicResidentialPool is recommended alongside ASP: true
  • Use Format: "markdown" for clean, LLM-friendly content
  • Read the page body via apiResponse.Result.Content; parse with apiResponse.Selector()

Related skills

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

More from scrapfly

Browse all skills

Web scraping using the Scrapfly Scraper API with the Python SDK

by scrapfly1 installs

Cross-tool golden rules for an autonomous Scrapfly web agent connected to the Scrapfly MCP server (web_scrape, screenshot, extract, classify_block, the Cloud...

by scrapfly

Threshold-based alerting on Scrapfly account metrics. Wire up rules like "alert me when scrape success rate drops below 95% for 10 minutes" and receive notif...

by scrapfly

Automate cloud browsers using the Scrapfly Cloud Browser API with Python Playwright

by scrapfly

Use the Scrapfly CLI (`scrapfly`) to scrape web pages, capture screenshots, extract structured data with AI, crawl entire sites, and drive a cloud browser ov...

by scrapfly

Crawl entire websites using the Scrapfly Crawler API with the Python SDK

by scrapfly