Extract and Group Outbound Links via Firecrawl
Scrapes a webpage using the Firecrawl API to extract all links, then uses jq and shell utilities to find the most frequently linked domains.
Setup
- → export FIRECRAWL_API_KEY='your_api_key_here'
- → jq installed
Cost per run
Requires Firecrawl API credits (free tier available)
The one-liner
$ curl -sX POST https://api.firecrawl.dev/v1/scrape \
-H "Authorization: Bearer $FIRECRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://news.ycombinator.com", "formats": ["links"]}' \
| jq -r '.data.links[] | select(startswith("http")) | split("/")[2]' \
| sort | uniq -c | sort -nr \
| head -n 5What each stage does
- [01] curl
curl -sX POST https://api.firecrawl.dev/v1/scrape ... -d '{"url": "...", "format…Calls the Firecrawl API to scrape the target URL, explicitly requesting only the extracted links in the JSON response. - [02] jq
jq -r '.data.links[] | select(startswith("http")) | split("/")[2]'Iterates over the links array, filters for absolute URLs, and splits the string by '/' to isolate the domain name. - [03] sort
sort | uniq -c | sort -nrGroups the extracted domains, counts their occurrences, and sorts the results in descending order by frequency. - [04] head
head -n 5Limits the final output to the top 5 most frequently linked domains on the page.
Expected output (sample)
14 news.ycombinator.com 3 github.com 2 en.wikipedia.org 1 www.nytimes.com 1 arxiv.org
Caveats & tips
- Footgun: Relative links (e.g., `/about`) are filtered out by the `startswith("http")` selector, so internal link counts may be underrepresented if the site uses relative paths.
- Cost/Permission: Requires a valid Firecrawl API key; scraping large sites or using advanced extraction formats consumes your monthly API credits.