ws-scraper is a Go-based scraper for Weiss Schwarz data from:
https://ws-tcg.com/(Japanese)https://en.ws-tcg.com/(English)
It can fetch card data, product listings, expansion lists, and deck rules. The repository includes both a CLI (wsoffcli) and an importable Go package (fetch) for programmatic use.
The scraper can export:
- card JSON files grouped by language, set, and release
- booster card lists
- expansion lists printed to stdout
- deck rules as a single JSON file
There is also a products command for exporting product metadata to product.json.
The scraper can also be used directly from Go via fetch/.
Create a client:
client, err := fetch.NewClient(
fetch.WithRequestsPerSecond(1),
fetch.WithBurst(1),
fetch.WithMaxRetries(4),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()Main APIs exposed by the fetch package:
fetch.NewClient(opts ...fetch.Option) (*fetch.Client, error)(*fetch.Client).Cards(ctx, cfg) ([]fetch.Card, error)(*fetch.Client).CardsStream(ctx, cfg, ch) error(*fetch.Client).Boosters(ctx, cfg) (map[string]fetch.Booster, error)(*fetch.Client).ExpansionList(ctx, cfg) (map[int]string, error)(*fetch.Client).Products(ctx, page) ([]fetch.ProductInfo, error)(*fetch.Client).DeckRules(ctx, cfg) (fetch.DeckRules, error)(*fetch.Client).DeckConstruction(ctx, cfg) ([]fetch.TitleDeckGroup, error)
Common option helpers:
fetch.WithRequestsPerSecondfetch.WithBurstfetch.WithNetworkConcurrencyfetch.WithMaxRetriesfetch.WithProxyURLfetch.WithCachefetch.WithRespectRobotsfetch.WithRequestTimeoutfetch.WithLogger
Example: fetch cards directly in Go:
cards, err := client.Cards(context.Background(), fetch.Config{
Language: fetch.English,
SetCode: []string{"IMC"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println("cards fetched:", len(cards))Example: fetch normalized deck-construction rules:
rules, err := client.DeckRules(context.Background(), fetch.DeckRulesConfig{
Language: fetch.English,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("title groups:", len(rules.TitleDeckGroups))Requirements:
- Go 1.21+
Build locally:
go build -o wsoffcliRun without installing:
go run . --helpCross-platform builds:
./build.shBuild the image:
docker build -t wsoffcli .Run it with the current directory mounted as output:
docker run --rm -v "$PWD:/data" wsoffcli fetch --lang en -n IMCThe container writes output under /data.
Fetch all cards whose set code starts with IMC from the English site:
./wsoffcli fetch --lang en -n IMCFetch multiple set prefixes by separating them with ##:
./wsoffcli fetch --lang en -n BD##IMFetch a specific expansion:
./wsoffcli fetch --lang ja --expansion 159Fetch recent products only:
./wsoffcli fetch --lang en --recentExport booster lists instead of individual card files:
./wsoffcli fetch --lang en --export boosterWrite deck rules:
./wsoffcli fetch --lang en --export deckrulesExport product metadata:
./wsoffcli products --page 1Default output paths:
- cards:
cards/<lang>/<set>/<release>/<set>-<release>-<id>.json - boosters:
boosters/<lang>/<release>.json - deck rules:
deck-rules_en.jsonordeck-rules_ja.json - products:
product.json
You can override card and booster directories with --cardDir and --boosterDir.
Global flags:
--expansion: official expansion number--title: official title number--neo,-n: set code prefix filter, supports multiple values with##--log,-l: log level (debug,info,warn,error)--rps: global request rate limit--burst: request burst size--net-concurrency: maximum concurrent network requests--max-retries: maximum retries per request--proxy-url: fixed upstream proxy--cache-dir: enable on-disk HTTP response caching--cache-ttl: cache lifetime, default24h--respect-robots: honorrobots.txtand crawl delays
fetch flags:
--lang:enorja--export,-e:card,booster,deckrules, orexpansionlist--recent: fetch recent products--allrarity,-a: include alternate rarities--pagestart,-p: start from a specific page--reverse,-r: reverse page order
--expansionuses the official site expansion ID.--titleuses the official site title ID.- These values are distinct from each other.
- English and Japanese sites do not share the same numbering.
- Title lookup is only supported where the upstream site exposes it.
See doc/expansion_list.md for a snapshot of known expansion IDs.
Generated command reference lives under doc/:
Regenerate them with:
./wsoffcli gendocRun the test suite:
go test ./...Apache 2.0. See LICENSE.