diff --git a/.actor/input_schema.json b/.actor/input_schema.json new file mode 100644 index 0000000..d4e8eb5 --- /dev/null +++ b/.actor/input_schema.json @@ -0,0 +1,48 @@ +{ + "title": "Pry Scraper", + "type": "object", + "schemaVersion": 1, + "properties": { + "urls": { + "title": "URLs to scrape", + "type": "array", + "items": { + "type": "string", + "pattern": "^https?://" + } + }, + "max_pages": { + "title": "Max pages", + "type": "integer", + "default": 10, + "minimum": 1, + "maximum": 1000 + }, + "timeout": { + "title": "Timeout (seconds)", + "type": "integer", + "default": 30, + "minimum": 5, + "maximum": 120 + }, + "output_format": { + "title": "Output format", + "type": "string", + "default": "markdown", + "enum": [ + "markdown", + "html", + "text" + ] + }, + "crawl": { + "title": "Crawl linked pages", + "type": "boolean", + "default": false + } + }, + "description": "Scrape any website with Pry's 12-tier fallback chain.", + "required": [ + "urls" + ] +} \ No newline at end of file diff --git a/.actor/src/main.py b/.actor/src/main.py new file mode 100644 index 0000000..65e4c78 --- /dev/null +++ b/.actor/src/main.py @@ -0,0 +1,23 @@ +"""Pry — Apify Actor entry point. + +Thin wrapper around the SDK-aware entry in apify_actor.py. The Apify +platform invokes this file via Dockerfile.apify as +``python /usr/src/app/.actor/src/main.py``; we re-export ``main()`` +so both the legacy ``python -m apify_actor`` invocation and the +standard .actor/src/main.py convention work. + +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Rug Munch Media LLC +# +# Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper +# Licensed under MIT. See LICENSE. +""" + +from __future__ import annotations + +import asyncio + +from apify_actor import main + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/Dockerfile.apify b/Dockerfile.apify index f6b1b15..f3abe7a 100644 --- a/Dockerfile.apify +++ b/Dockerfile.apify @@ -22,4 +22,4 @@ RUN pip install --no-cache-dir "apify~=1.7.0" \ ENV PRY_ACTOR=true ENV PYTHONUNBUFFERED=1 -ENTRYPOINT ["python3", "-m", "apify_actor"] +ENTRYPOINT ["python3", "/usr/src/app/.actor/src/main.py"] diff --git a/Makefile b/Makefile index 9a485fa..3434e7c 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,22 @@ SHELL := /bin/bash PYTHON := python3 -.PHONY: help install dev lint format typecheck test security check clean precommit ci +.PHONY: help install dev lint format typecheck test security check clean precommit ci actor-build help: @echo "Pry Makefile" @echo "" - @echo " install Install dependencies" - @echo " dev Start dev server" - @echo " lint Run ruff check" - @echo " format Run ruff format" - @echo " typecheck Run mypy" - @echo " test Run pytest" - @echo " security Run bandit + safety" - @echo " check Full audit (lint + typecheck + test)" - @echo " clean Remove build artifacts" - @echo " precommit Run ruff + mypy + bandit" + @echo " install Install dependencies" + @echo " dev Start dev server" + @echo " lint Run ruff check" + @echo " format Run ruff format" + @echo " typecheck Run mypy" + @echo " test Run pytest" + @echo " security Run bandit + safety" + @echo " check Full audit (lint + typecheck + test)" + @echo " clean Remove build artifacts" + @echo " precommit Run ruff + mypy + bandit" + @echo " actor-build Regenerate .actor/input_schema.json from apify_schema.py" install: pip install -e ".[dev]" @@ -46,3 +47,9 @@ clean: precommit: lint format typecheck security ci: precommit test + +# Regenerate .actor/input_schema.json from the ApifySchemaBuilder fluent API. +# Pin schema version + title so Apify Console recognises the file. +actor-build: + $(PYTHON) -c "from apify_schema import ApifySchemaBuilder, StringField, IntegerField, BooleanField, EnumField; b = ApifySchemaBuilder('Pry Scraper', 'Scrape any website with Pry\\'s 12-tier fallback chain.'); b.add_array('urls', 'URLs to scrape', {'type': 'string', 'pattern': '^https?://'}, required=True).add_integer('max_pages', 'Max pages', default=10, minimum=1, maximum=1000).add_integer('timeout', 'Timeout (seconds)', default=30, minimum=5, maximum=120).add_enum('output_format', 'Output format', ['markdown','html','text'], default='markdown').add_boolean('crawl', 'Crawl linked pages', default=False); import json, pathlib; pathlib.Path('.actor').mkdir(exist_ok=True); pathlib.Path('.actor/input_schema.json').write_text(json.dumps(b.build_input_schema(), indent=2))" + @echo "wrote .actor/input_schema.json"