Skip to content
Agentmart
Submit a tool

dk-wikibot

Fetch, search, and extract information from Wikipedia, Wikidata, or any MediaWiki-based wiki using pywikibot.

Skill by dushyantkhosla

IndexedApache-2.0
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/dushyantkhosla-dk-wikibot

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Fetch, search, and extract information from Wikipedia, Wikidata, or any MediaWiki-based wiki using pywikibot. Use when the user asks to scrape Wikipedia articles or infoboxes, iterate over Wikipedia categories, query Wikidata entities and claims (structured facts), look up award winners, historical lists, or biographical data from Wikimedia projects. Also triggers on phrases like "use the wikibot skill", "look up on Wikipedia", or "query Wikidata". Does not handle live web searches, non-Wikimedia sites, or tasks requiring a logged-in Wikipedia account.

Use cases: data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/dk-wikibot

What's inside

Skill name
dk-wikibot
Description
Fetch, search, and extract information from Wikipedia, Wikidata, or any MediaWiki-based wiki using pywikibot. Use when the user asks to scrape Wikipedia articles or infoboxes, iterate over Wikipedia categories, query Wikidata entities and claims (structured facts), look up award winners, historical lists, or biographical data from Wikimedia projects. Also triggers on phrases like "use the wikibot skill", "look up on Wikipedia", or "query Wikidata". Does not handle live web searches, non-Wikimedia sites, or tasks requiring a logged-in Wikipedia account.
License
Apache-2.0
Compatibility
Requires Python 3.8+, pywikibot, mwparserfromhell (uv add pywikibot mwparserfromhell). Read-only tasks require no credentials.
Metadata
author: dushyantkhosla · version: 1.0 · opencode/autoinvoke: false
Instructions
195 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • api.md · references/

SKILL.md (first lines)

# Pywikibot Skill

Pywikibot wraps the MediaWiki API. For **read-only** tasks (the common case), no credentials are
needed — set `PYWIKIBOT_NO_USER_CONFIG=1`.

Always write a standalone Python script and execute it via `bash_tool`. Do not import pywikibot
interactively — it makes blocking network calls and must run as a script.

## Setup

```bash
uv add pywikibot mwparserfromhell
export PYWIKIBOT_NO_USER_CONFIG=1
```

Every script must start with:

```python
import os; os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
import pywikibot
```

---

## Step-by-step instructions

### 1. Fetch a Wikipedia article

```python
import os; os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
import pywikibot

site = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(site, 'Grammy Award for Best Rock Song')
print(page.text[:3000])  # raw wikitext — inspect this first before parsing
```

Always inspect `page.text` before writing any parser. Wikitext structure varies per article.

### 2. Parse wikitext

```python
import mwparserfromhell
wikicode = mwparserfromhell.parse(page.text)
templates = wikicode.filter_templates()  # e.g. {{won}}, {{nom}}, {{infobox}}
```

Alternatively, use regex directly on `page.text`:

```python
import re
year_sections = re.split(r'\n==\s*(\d{4})\s*==\n', page.text)
links = re.findall(r'\[\[([^\|\]]+)(?:\|[^\]]+)?\]\]', block)
```

### 3. Iterate a Wikipedia category

```python
import os; os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
import pywikibot

site = pywikibot.Site('en', 'wikipedia')
cat = pywikibot.Category(site, 'Category:Grammy Award for Best Rock Song')
for page in cat.articles(total=50):
    print(page.title())
```

Use `cat.subcategories()` for subcats, `cat.members()` for everything.

### 4. Query Wikidata via SPARQL

Best for clean structured data (winners, dates, relationships). Find the QID for any entity at
https://www.wikidata.org/wiki/Special:Search first, then use it in the query.

```python
import os; os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
from pywikibot.data import sparql

QUERY = """
SELECT ?year ?songLabel ?artistLabel WHERE {
  ?award wdt:P31 wd:Q1377714 .       # instance of Grammy Award for Best Rock Song
  ?award wdt:P585 ?date .
  BIND(YEAR(?date) AS ?year)
  FILTER(?year >= 2010)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?year
"""
results = sparql.SparqlQuery().select(QUERY)
for row in results:
    print(row)
```

### 5. Fetch a Wikidata item directly

```python
import os; os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
import pywikibot

site = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(site, 'Douglas Adams')
item = pywikibot.ItemPage.fromPage(page)
item.get()
print(item.labels.get('en'))
print(item.claims)  # dict of property_id -> list of Claims
```

---

## Decision guide

| Task | Approach |
|------|----------|
| Award winner lists, formatted tables | Wikipedia `page.text` + wikitext parsing |
| Clean structured facts (dates, IDs, relationships) | Wikidata SPARQL or `ItemPage` |
| Category membership | `Category.articles()` |
| Multiple entities at once | Wikidata SPARQL (most efficient) |

---

From dushyantkhosla/agent-skills, Apache-2.0.

More from dushyantkhosla/agent-skills

Signals

Stars
0
Forks
1
Open issues
0
Last commit (this folder)
Oct 7, 2026 (20 days ago)

From GitHub (fetched Oct 24, 2026).

Details

Version
1.0
License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from dushyantkhosla

Cite this page

dk-wikibot skill. Agent Mart. https://agentmart.dev/skills/dushyantkhosla-dk-wikibot (last updated 2026-10-24)