Use Yandex SERP & Knowledge Graph Scraper with Python
Query Yandex across 17 regional domains and get organic results, ads, knowledge graph cards, inline images and videos, and related searches per page, with language, region and recency filters.
1. Choose the data you need
Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.
2. Prepare a source-based input
This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.
{
"failIfEmpty": false,
"fixTypos": true,
"includeAds": true,
"includeBlocks": true,
"includeRelatedSearches": true,
"maxItems": 1,
"maxPages": 1,
"mode": "search",
"outputFormat": "pages",
"queries": [
"python programming"
]
}
Download input.example.json and save your reviewed copy as input.json.
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | required | Search by keyword or parse existing Yandex SERP URLs. |
queries | array | optional | One or more search queries (mode=search). Each query is processed separately. |
serpUrls | array | optional | Yandex search-result URLs, one per page (mode=byUrls). Direct Yandex URLs and translated Yandex URLs are accepted. |
domain | string | optional | Regional Yandex front. yandex.com is the international entry point; Yandex may serve it from its Russia front (reported as servedDomain). |
language | string | optional | Yandex interface and search language. Match it to your query language to keep result text untranslated. |
region | string | optional | Named Yandex region preset. Leave empty to use Yandex's default region. regionId overrides this value. |
regionId | integer | optional | Numeric Yandex region ID (lr). Overrides the Region preset. For example 213 is Moscow and 983 is Turkey. |
maxPages | integer | optional | Number of result pages to read per query (1-25). Yandex serves at most 25 pages. |
startPage | integer | optional | Zero-based page to start from (0-24). Use it to resume a deep result window. |
maxItems | integer | optional | Global cap on unique items across all queries and pages (1-10,000). In rows mode this is the row count; in pages mode it caps the items inside page records. |
timeFilter | string | optional | Limit results by recency. The values map to Yandex's own past-day, past-two-weeks and past-month filters. |
fixTypos | boolean | optional | Let Yandex correct misspelled queries. Turn it off for exact-match searches. |
includeAds | boolean | optional | Include sponsored Yandex Direct rows with their click URL and displayed domain. |
includeBlocks | boolean | optional | Include knowledge graph, AI answer, inline images, inline videos, products, local companies and weather when present. |
includeRelatedSearches | boolean | optional | Include the related-search suggestions shown below the results (requires Include SERP Blocks). |
outputFormat | string | optional | Page records preserve the existing dataset shape; rows emit one flat record per result or block item. |
failIfEmpty | boolean | optional | Fail the run when no records were produced, instead of finishing with an empty dataset. |
3. Start an Actor run
Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.
Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.
import json
import os
import urllib.request
# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
actor_input = json.load(stream)
token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
"https://api.apify.com/v2/acts/k8mATrelzfQPwRaY0/runs?timeout=120&maxTotalChargeUsd=0.50",
data=json.dumps(actor_input).encode("utf-8"),
headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.
4. Inspect the actual results
Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.
Yandex search pages or flat result rows with organic results, ads, knowledge graph and AI answers, inline images and videos, products, local companies, weather and related searches.
Questions before you run
Which inputs are required?
The published required fields are mode
What does this guide verify?
The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.
What if the run request times out?
Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.
Generated from source build bSVngXIyYRPALNUTs and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.