Seo Jsonld Extractor
Pricing
$0.01 / actor start
Seo Jsonld Extractor
Pricing
$0.01 / actor start
Rating
0.0
(0)
Developer
Eichan Jolly
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
4 days ago
Last modified
Categories
Features
Share
JSON-LD Block Extractor
What it does
Fetches one page and extracts every HTML <script type="application/ld+json"> block in document order, returning one dataset item per block. It retains the exact parsed JSON value in data, and gathers the actual @type string values found anywhere in that value. Malformed JSON becomes its own item with a readable parseNote; later blocks are still processed.
Who it is for
SEO auditors, structured-data maintainers, site owners, and developers checking what JSON-LD a page actually embeds.
Input
Supply one publicly reachable HTTP/HTTPS URL (no account or API key):
{"url": "https://yoast.com/author-publisher-entities-seo/"}
This is also the prefilled Store example; it is a real public page. It may change after publication. The only configurable field is url. The Actor will request the target site’s /robots.txt and, if permitted, fetch the page itself.
Output
sourceUrl (string or null on invalid input), blockIndex (1-based integer or null), types (list of discovered @type strings), data (parsed JSON value or null), status (ok, malformed, no_jsonld, or error), parseNote (string or null), error (string or null).
Example actual dataset item, recorded by the included local script-mode smoke test (the 127.0.0.1 address is a disposable test fixture, not the public prefill):
{"sourceUrl": "http://127.0.0.1:43373/page","blockIndex": 1,"types": ["Article","Person"],"data": {"@context": "https://schema.org","@graph": [{"@type": "Article","headline": "Test post"},{"@type": "Person","name": "Eichan"}]},"status": "ok","parseNote": null,"error": null}
The script-mode fixture includes one valid JSON-LD @graph and one malformed JSON-LD block, producing two records. See tests/evidence/smoke_dataset.json for all actual smoke-test records, including malformed JSON-LD when applicable.
How to run
On Apify, paste the URL in the input form and run the Actor. The input is loaded in this exact precedence order:
- Parse
ACTOR_INPUT_JSONif set (including when it contains invalid JSON; no silent fallback). - Otherwise use
GET https://api.apify.com/v2/key-value-stores/{APIFY_DEFAULT_KEY_VALUE_STORE_ID}/records/INPUTwithAuthorization: Bearer {APIFY_TOKEN}when the default key-value store ID exists. - Otherwise read
./storage/key_value_stores/default/INPUT.jsonrelative to the process working directory.
On Apify, results are appended to the default dataset by an authorized REST API POST. Locally, one JSON file per item appears under storage/datasets/default/.
To run locally from this Actor folder:
export ACTOR_INPUT_JSON='{"url": "https://yoast.com/author-publisher-entities-seo/"}'python src/main.py
Or put the same JSON in storage/key_value_stores/default/INPUT.json and run python src/main.py with ACTOR_INPUT_JSON unset. Only Python 3.12+ standard-library modules are required.
To rerun verifiable offline tests:
python -m unittest discover -s tests -p test_actor.py -vpython tests/run_smoke.py
The smoke runner launches a local HTTP fixture and executes python src/main.py as a subprocess with a valid ACTOR_INPUT_JSON. It writes the full terminal output, valid input, and produced dataset records to tests/evidence/. ACTOR_TEST_ALLOW_LOOPBACK=1 is only set by this local test runner, never by default.
Limits and error handling
It reads server-returned HTML only, without running JavaScript. JSON-LD added by client-side scripts is not included. It does not follow src attributes, external URLs, or validate schema.org semantics or Google rich-results eligibility. A page with zero JSON-LD blocks produces one no_jsonld item, rather than an empty dataset. Block indexes start at 1 and duplicate blocks are preserved. Malformed JSON is not repaired or inferred.
- One page per run. No general crawling, search-result scraping, login, or third-party Python packages.
- Two HTTP requests maximum in a normal run (robots.txt and the page), with at most three same-host redirects for each request. The page is limited to 2 MB; robots.txt is limited to 200 KB; each request has a 12-second timeout.
- By default, local/private/reserved IP addresses and nonstandard ports are rejected; cross-host redirects are rejected. The actor checks DNS addresses but is not a hardened defence against DNS rebinding on hostile hostnames. Use only public sites you are authorized to inspect.
- Robots.txt opt-outs are respected; missing robots.txt (404/410) is allowed. If the page cannot be fetched, or input is invalid, the Actor writes a stable
errordataset record and prints a short message, not a traceback. A failed run may exit nonzero even if its error item is written. - Web content, robots policies, and site availability change. The public example is not part of the offline unit/smoke fixture, so cloud execution must be checked after deploying.
Suggested Store categories and pricing
Categories: SEO tools, Developer tools, Marketing.
Suggested $0.01 per run, independent of the number of blocks. This is a proposed Store price only; no monetization or billing is configured.
Deployment state
Source-only deliverable, not published. No Apify cloud runs or billing configuration have been performed.