{"slug": "pulling-semrush-ai-visibility-and-seo-metrics-with-python", "title": "Pulling Semrush AI Visibility and SEO Metrics with Python", "summary": "A developer published a Python workflow that uses the Semrush All-in-One Scraper on Apify to pull classic SEO metrics and AI Search visibility data in a single request. The actor's domain mode returns authority scores, traffic, backlink profiles, and per-LLM mention and citation counts across ChatGPT, Google AI Overview, AI Mode, and Gemini, with an example script using apify-client and pandas to snapshot competitor domains to CSV. The author notes the actor supports up to 100 domains per run with configurable concurrency, avoiding manual exports for agencies tracking dozens of rivals.", "body_md": "Most SEO dashboards still treat Google blue links as the whole picture. Over the past year, though, clients started asking a harder question: how often do ChatGPT, Gemini, and Google AI Overviews actually cite our domain compared to our rivals?\n\nYou can click through Semrush by hand to check this, domain by domain, or pay for API add-on units on top of a monthly seat. When you track 30 to 100 competitor domains every Monday, manual exports break down fast.\n\nOne practical alternative is running the [Semrush All-in-One Scraper](https://apify.com/pro100chok/semrush-scraper?fpr=raven) on Apify. It has over 4,600 users and more than 320,000 runs, and it packages four distinct modes (`domain`, `keyword`, `seo_audit`, and `top_websites`) behind one JSON interface.\n\nIn `domain` mode, a single request pulls both classic SEO totals and AI Search visibility into one flat-plus-nested JSON object:\n\n| Metric group | Example fields returned | \n|---|---|\n| Domain authority | `authority_score` ,`moz_domain_authority` ,`moz_spam_score` | \n| Search traffic | `organic_traffic` ,`total_traffic` ,`organic_keywords` ,`paid_traffic` | \n| Link profile | `backlinks` ,`referring_domains` ,`backlinks_list` ,`referring_domains_list` | \n| AI Search | `ai_visibility` ,`ai_mentions` ,`ai_cited_pages` ,`ai_search.by_llm` | \n\nThe `ai_search.by_llm` section breaks down mentions and cited pages across ChatGPT, Google AI Overview, AI Mode, and Gemini. It also includes `top_cited_sources`, which lists third-party sites that models frequently cite alongside a domain. For digital PR teams, that list is basically a ready-made outreach target sheet.\n\nRow-level lists are opt-in, so you do not have to haul megabytes of nested arrays when you only need headline KPIs. Toggle `include_organic_keywords`, `include_backlinks` (up to 80 per domain via `backlinks_limit`), or `include_referring_domains` (up to 60 via `referring_domains_limit`) whenever you want deeper tables.\n\nHere is a small script using `apify-client` and `pandas` that checks a batch of SaaS competitors in the US database, grabs their Moz scores and top keywords, and saves a clean CSV snapshot.\n\n``` python\nimport os\nimport pandas as pd\nfrom apify_client import ApifyClient\n\nclient = ApifyClient(os.environ[\"APIFY_TOKEN\"])\n\nrun_input = {\n    \"mode\": \"domain\",\n    \"domains\": [\"backlinko.com\", \"ahrefs.com\", \"moz.com\", \"searchengineland.com\"],\n    \"database\": \"us\",\n    \"include_moz\": True,\n    \"include_organic_keywords\": True,\n    \"include_backlinks\": True,\n    \"backlinks_limit\": 20,\n    \"concurrency\": 20,\n}\n\nrun = client.actor(\"pro100chok/semrush-scraper\").call(run_input=run_input)\nitems = list(client.dataset(run[\"defaultDatasetId\"]).iterate_items())\n\nrows = []\nfor item in items:\n    by_llm = {\n        entry[\"llm\"]: entry.get(\"mentions\", 0)\n        for entry in item.get(\"ai_search\", {}).get(\"by_llm\", [])\n    }\n    rows.append({\n        \"domain\": item.get(\"domain\"),\n        \"authority_score\": item.get(\"authority_score\"),\n        \"organic_traffic\": item.get(\"organic_traffic\"),\n        \"referring_domains\": item.get(\"referring_domains\"),\n        \"ai_visibility\": item.get(\"ai_visibility\"),\n        \"chatgpt_mentions\": by_llm.get(\"ChatGPT\", 0),\n        \"ai_overview_mentions\": by_llm.get(\"AI Overview\", 0),\n        \"moz_da\": item.get(\"moz_domain_authority\"),\n    })\n\ndf = pd.DataFrame(rows).sort_values(\"ai_visibility\", ascending=False)\ndf.to_csv(\"weekly_seo_ai_snapshot.csv\", index=False)\nprint(df.to_string(index=False))\n```\n\nNotice `concurrency: 20`. Because the actor accepts up to 100 domains per run, a 50-domain agency portfolio finishes in one short job instead of looping through single-domain requests.\n\nIf you already have this actor wired into your pipeline, you can reuse the exact same API call pattern for three adjacent tasks:\n\n`keyword`` keywords` and pick a regional `database` (90+ countries or `worldwide`). You get search volume, CPC, Keyword Difficulty, search intent, 12-month trend data, related questions, and live SERP snapshots.`seo_audit`` response_time_ms`, `h1_count`, `word_count`, `images_missing_alt`, `canonical`, `has_robots_txt`, and `has_sitemap` right next to the domain's Semrush organic context.`top_websites`` country_top_websites` and `industry_top_websites` for market sizing.\nInstead of paying a recurring monthly subscription just to export a few hundred rows, billing is strictly pay-per-event on each dataset result returned: **$4.00 per 1,000 results on paid Apify plans** ($15.00 per 1,000 on the free tier).\n\nFor a weekly check of 50 domains (200 results a month), that comes out to roughly $0.80 a month on a paid Apify plan. Even if you run quarterly audits on 1,000 domains, you only spend $4.00 and keep your pipeline completely serverless.\n\nIf your team needs Semrush domain metrics, backlink samples, and per-LLM AI Search visibility inside Python notebooks, Looker Studio, or automated Slack alerts, give the [Semrush All-in-One Scraper](https://apify.com/pro100chok/semrush-scraper?fpr=raven) a test run on five of your own URLs first. Inspect the nested JSON once, map the columns you care about, and schedule it to run while you sleep.", "url": "https://wpnews.pro/news/pulling-semrush-ai-visibility-and-seo-metrics-with-python", "canonical_source": "https://dev.to/pro100chok/pulling-semrush-ai-visibility-and-seo-metrics-with-python-a2e", "published_at": "2026-12-06 15:08:25+00:00", "updated_at": "2026-12-06 15:15:12.215944+00:00", "lang": "en", "topics": ["generative-engine-optimization", "ai-search", "ai-tools", "developer-tools"], "entities": ["Semrush", "Apify", "ChatGPT", "Gemini", "Google AI Overviews", "pandas"], "also_reported_by": [], "takeaway": "Semrush's domain-mode scraper returns AI visibility, per-LLM mention counts, and cited pages alongside classic SEO metrics in one JSON call, so a 50-domain portfolio can be snapshotted in a single run at concurrency 20 instead of looping single-domain requests.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/pulling-semrush-ai-visibility-and-seo-metrics-with-python", "markdown": "https://wpnews.pro/news/pulling-semrush-ai-visibility-and-seo-metrics-with-python.md", "text": "https://wpnews.pro/news/pulling-semrush-ai-visibility-and-seo-metrics-with-python.txt", "jsonld": "https://wpnews.pro/news/pulling-semrush-ai-visibility-and-seo-metrics-with-python.jsonld"}}