# Wikipedia-scraper (`pluzgi/wikipedia-scraper`) Actor

The scraper searches Wikipedia for a given term, extracts the titles and URLs of search results, and retrieves the last modification date from each page.

- **URL**: https://apify.com/pluzgi/wikipedia-scraper.md
- **Developed by:** [pluzgi](https://apify.com/pluzgi) (community)
- **Categories:** Automation, Lead generation, Developer tools
- **Stats:** 64 total users, 0 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Wikipedia Scraper Actor

### 📖 What does it do?

The Wikipedia Scraper is your one-stop shop for mining Wikipedia like a pro. It extracts article titles, URLs, and last modification dates from English (EN) or German (DE) Wikipedia. Whether you need just a handful of results or an exhaustive list, this scraper has you covered—no fluff, just actionable data.

***

### 🚀 Why use this Actor?

- **Exact Phrase Searches**: The scraper runs precise searches by wrapping your search term in quotes. No more messy, irrelevant results!
- **Language Selection**: Choose between EN and DE Wikipedia for multilingual data mining.
- **Pagination Power**: This Actor handles pagination like a champ—extract up to 1000 results in one run.
- **Developer Friendly**: Flexible input schema, detailed logs, and outputs in a structured JSON/CSV/XML/EXCEL/HTML/RSS/JSONL format.

***

### 🛠️ How does it work?

1. **Input your parameters**:
   - `language`: Choose between EN Wikipedia or DE Wikipedia.
   - `search_term`: Provide your search term. Make it specific for the best results.
   - `max_results`: Decide how many results you want (default: 50, max: 1000).

2. **Hit the Run Button**:\
   The Actor navigates Wikipedia search pages, extracts articles, handles pagination, and pushes all the good stuff into the output.

3. **Get your data**:\
   Titles, URLs, and last modification dates in a clean, developer-ready format.

***

### 📝 Input Parameters

| Parameter    | Type    | Default       | Description                                           |
|--------------|---------|---------------|-------------------------------------------------------|
| `language`   | String  | EN Wikipedia  | Choose between EN Wikipedia or DE Wikipedia.         |
| `search_term`| String  | Required      | The exact phrase you want to search for.             |
| `max_results`| Integer | 50            | Number of results to scrape (min: 1, max: 1000).     |

***

### 🛑 Caveats

- If your search term is too generic, Wikipedia might throw irrelevant results your way. Be precise!
- The Actor assumes your search term is an exact match (wrapped in quotes). No approximate matching here—precision is key.
- Results exceeding `max_results` are ignored. Configure appropriately.

***

### 📦 Output

You’ll get structured data, containing:

- **`language`**: The Wikipedia language version used.
- **`title`**: The cleaned article title (no "– Wikipedia" nonsense).
- **`url`**: The article URL.
- **`last_modified`**: The raw last-modified string.
- **`last_modified_date`**: The last-modified date in `Day Month Year` format.

#### Example:

```json
{
  "search_term": "Stiftung Schweiz",
  "language": "DE Wikipedia",
  "title": "Stiftung (Schweiz)",
  "url": "https://de.wikipedia.org/wiki/Stiftung_(Schweiz)",
  "last_modified": "Diese Seite wurde zuletzt am 18. Juni 2024 um 08:44 Uhr bearbeitet.",
  "last_modified_date": "18. Juni 2024"
}
```

***

### 🔧 Under the Hood

This Actor uses **Playwright** for precise scraping and **Apify's Request Queue** for managing pagination. It’s all written in Python, so feel free to fork and extend it to suit your needs.

***

### 🤔 Need Help?

If you have questions, suggestions, or just want to share how this Actor made your life easier, feel free to reach out on the [Apify community forums](https://forum.apify.com/).

***

🎉 Test it Today!
Stop manually clicking through Wikipedia pages and let this Actor do the heavy lifting. Search smarter, scrape faster, and enjoy the magic of automation.

### 🎉 Test it Today!

Stop manually clicking through Wikipedia pages and let this Actor do the heavy lifting. Search smarter, scrape faster, and enjoy the magic of automation—[try it now](https://apify.com/)!

# Actor input Schema

## `search_term` (type: `string`):

The term to search for on Wikipedia.

## `language` (type: `string`):

Select the language version of Wikipedia.

## `max_results` (type: `integer`):

The maximum number of results to scrape.

## Actor input object example

```json
{
  "search_term": "Stiftung Schweiz",
  "language": "EN Wikipedia",
  "max_results": 50
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "search_term": "Stiftung Schweiz",
    "language": "EN Wikipedia"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pluzgi/wikipedia-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "search_term": "Stiftung Schweiz",
    "language": "EN Wikipedia",
}

# Run the Actor and wait for it to finish
run = client.actor("pluzgi/wikipedia-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "search_term": "Stiftung Schweiz",
  "language": "EN Wikipedia"
}' |
apify call pluzgi/wikipedia-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pluzgi/wikipedia-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tnoEmytT9TRYvdTJT/builds/m3L08HOS12MDQFAMd/openapi.json
