PlaybooksMonitor Google News
Build a monitoring pipeline with deduplication
Remember the articles already seen, so each run reports only new ones.
Store seen article URLs so repeated runs don't produce duplicate alerts.
import json
import os
import requests
API_KEY = os.environ["AUTOM_API_KEY"]
def get(path, params):
response = requests.get(f"https://api.autom.dev{path}", headers={"x-api-key": API_KEY}, params=params)
if not response.ok:
raise SystemExit(f"Error {response.status_code}: {response.text}")
return response.json()
KEYWORDS = ["OpenAI", "Anthropic", "Mistral AI"]
SEEN_FILE = "seen_articles.json"
def load_seen():
if not os.path.exists(SEEN_FILE):
return set()
with open(SEEN_FILE, encoding="utf-8") as file:
return set(json.load(file))
seen = load_seen()
new_count = 0
for keyword in KEYWORDS:
data = get("/v1/google/news", {"query": keyword, "gl": "us", "hl": "en"})
for article in data.get("organic_results", []):
if article["link"] not in seen:
seen.add(article["link"])
print(f" [{keyword}] {article['title']} — {article['source']}")
new_count += 1
with open(SEEN_FILE, "w", encoding="utf-8") as file:
json.dump(sorted(seen), file)
print(f"Found {new_count} new article(s).")Schedule this script with a cron job (e.g. every hour) or a task scheduler to receive continuous coverage monitoring. Combine multiple keywords in one run to minimize credit usage.