Package com.tnsai.tools.scraping
Class ScrapingTools
java.lang.Object
com.tnsai.tools.scraping.ScrapingTools
Function-shape Apify scraping tools — universal web-scraping platform with
2,600+ pre-built actors. Replaces the legacy
ApifyTool (single
dispatched tool).
| Method | Endpoint | Idempotent |
|---|---|---|
apifyRunActor(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>) | POST /v2/acts/{id}/run-sync-get-dataset-items | false (executes a scrape) |
apifySearchActors(java.lang.String, int) | GET /v2/store | true (read-only catalog) |
apifyActorInfo(java.lang.String) | GET /v2/acts/{id} | true (read-only metadata) |
Requires APIFY_API_KEY. Sign up at apify.com.
Popular actor IDs (LLM can pass these directly to apifyRunActor(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)):
junglee/amazon-crawler— Amazon productsstreamers/youtube-scraper— YouTube videos / channelsapify/website-content-crawler— generic site crawlcompass/crawler-google-places— Google Maps placesclockworks/tiktok-scraper— TikTok postsapify/instagram-scraper— Instagram profiles
- Since:
- 0.5.7 (Phase 2 batch 17a — built-in tool migration to function shape, see #188)
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor — picks APIFY_API_KEY from env.ScrapingTools(String apiKey) Explicit-key constructor.ScrapingTools(String apiKey, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP. -
Method Summary
Modifier and TypeMethodDescriptionapifyActorInfo(String actorId) apifyRunActor(String actorId, Map<String, Object> input) apifySearchActors(String query, int limit)
-
Constructor Details
-
ScrapingTools
public ScrapingTools()Default constructor — picks APIFY_API_KEY from env. -
ScrapingTools
Explicit-key constructor. -
ScrapingTools
public ScrapingTools(String apiKey, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP.
-
-
Method Details
-
apifyRunActor
@Tool(name="apify_run_actor", description="Run an Apify actor synchronously and return its dataset items as JSON. {actorId} is the actor\'s full id (e.g. \"junglee/amazon-crawler\", \"apify/website-content-crawler\"). {input} is the actor-specific JSON input map (see the actor\'s input schema). Returns the dataset items array. Read-timeout is 180s \u2014 pick a different actor (or use the async pattern) for long-running scrapes. Requires APIFY_API_KEY.", keywords={"apify","scrape","scraper","crawl","actor"}, idempotent=false) public String apifyRunActor(@ToolParam(description="Apify actor id (e.g. \"junglee/amazon-crawler\")") String actorId, @ToolParam(description="Actor input as a JSON map (consult the actor\'s input schema)",required=false) Map<String, Object> input) throws IOException- Throws:
IOException
-
apifySearchActors
@Tool(name="apify_search_actors", description="Search the Apify Store for actors by free-text {query}. {limit} clamps to [1, 100]. Returns the raw JSON store listing. Use this when the LLM doesn\'t already know an actor id and needs to discover one for a particular site / task. Requires APIFY_API_KEY.", keywords={"apify","search","actors","store","discovery"}, idempotent=true) public String apifySearchActors(@ToolParam(description="Free-text actor search query (e.g. \"linkedin profile\")") String query, @ToolParam(description="Max results (1..100); 0 \u2192 default 10",required=false,defaultValue="0") int limit) throws IOException - Throws:
IOException
-
apifyActorInfo
@Tool(name="apify_actor_info", description="Fetch metadata + input schema for a single Apify actor by id. Useful when the LLM needs to know what fields an actor\'s input map accepts before calling apify_run_actor. Requires APIFY_API_KEY.", keywords={"apify","actor","info","schema"}, idempotent=true) public String apifyActorInfo(@ToolParam(description="Apify actor id") String actorId) throws IOException - Throws:
IOException
-