Source Code
Naver News Search
Search Korean news articles using the Naver Search API.
Quick Start
Use the provided script to search news:
python scripts/search_news.py "๊ฒ์์ด" --display 10 --sort date
Options:
--display N: Number of results per page (1-100, default: 10)--start N: Start position for pagination (1-1000, default: 1)--sort sim|date: Sort by relevance (sim) or date (date, default: date)--after DATETIME: Only show news published after this time (ISO 8601 format, e.g.,2026-01-29T09:00:00+09:00)--min-results N: Minimum number of results to fetch (enables auto-pagination)--max-pages N: Maximum number of pages to try when auto-paginating (default: 5)--json: Output raw JSON instead of formatted text
Setup
Environment Variables
Required credentials from https://developers.naver.com/:
NAVER_CLIENT_ID=your_client_id
NAVER_CLIENT_SECRET=your_client_secret
Configuration locations:
- Sandbox (default): Add to
agents.defaults.sandbox.docker.envin OpenClaw config - Host: Add to
env.varsin OpenClaw config
Getting API Credentials
- Visit https://developers.naver.com/
- Register an application
- Enable "๊ฒ์" (Search) API
- Copy Client ID and Client Secret
- Add credentials to appropriate config section (see above)
Common Use Cases
Latest news on a topic
python scripts/search_news.py "AI ์ธ๊ณต์ง๋ฅ" --display 20 --sort date
Search with relevance ranking
python scripts/search_news.py "์ผ์ฑ์ ์" --sort sim
Filter by time (only recent news)
# News published after 9 AM today
python scripts/search_news.py "๊ฒฝ์ " --display 50 --sort sim --after "2026-01-29T09:00:00+09:00"
# News from the last hour (programmatic use)
python scripts/search_news.py "์๋ณด" --after "$(date -u -d '1 hour ago' '+%Y-%m-%dT%H:%M:%S%z')"
Auto-pagination for guaranteed minimum results
# Fetch at least 30 results (automatically requests multiple pages if needed)
python scripts/search_news.py "AI" --sort sim --after "2026-01-29T09:00:00+09:00" --min-results 30 --display 50
# Limit to 3 pages maximum
python scripts/search_news.py "๊ฒ์" --min-results 50 --max-pages 3
How auto-pagination works:
- Fetches first page (e.g., 50 results)
- Applies date filter (e.g., 10 results remain)
- If below
--min-results, automatically fetches next page - Stops when minimum is reached or
--max-pageslimit hit
Pagination for more results
# First 10 results
python scripts/search_news.py "๊ฒฝ์ " --display 10 --start 1
# Next 10 results
python scripts/search_news.py "๊ฒฝ์ " --display 10 --start 11
Using in Python Code
Import and use the search function directly:
from scripts.search_news import search_news
result = search_news(
query="๊ฒฝ์ ๋ด์ค",
display=10,
sort="date"
)
for item in result["items"]:
print(item["title"])
print(item["description"])
print(item["link"])
API Details
For complete API reference including response structure, error codes, and rate limits, see:
Notes
- Search queries must be UTF-8 encoded
- Results include
<b>tags around search term matches (strip them for clean text) - Daily limit: 25,000 API calls per application
linkfield may point to Naver News or original source depending on availability