SE::Wikipedia::Article - Scraper de artigos da Wikipedia
Visão geral do scraper
Scraper de artigos da Wikipedia. A entrada é um link para o artigo (ou o formato curto lang:title), a saída é o texto completo do artigo em plain text, descrição curta, link canônico, thumbnail e imagem original, categorias, versões de idiomas, Wikidata ID e metadados de revisão.
Os dados são obtidos através da MediaWiki Action API oficial (prop=extracts|info|pageimages|...). O idioma é determinado a partir da URL ou do prefixo da consulta. Os redirecionamentos da Wikipedia são processados automaticamente (por exemplo, USA → United States).
Para pesquisar artigos por palavras-chave, use o scraper SE::Wikipedia.
A funcionalidade do A-Parser permite salvar as configurações de extração de dados para uso posterior (presets), definir agendamentos de extração de dados e muito mais. A gravação dos resultados é possível no formato e estrutura que você desejar, graças ao poderoso motor de modelos integrado Template Toolkit.
Dados coletados
Os dados são coletados através da API https://{lang}.wikipedia.org/w/api.php.
- Título do artigo (
title) - Descrição curta (
description) - Texto completo do artigo em plain text (
text) - Link canônico (
link) - Prévia da imagem (
thumb) - Imagem original (
image) - Page ID (
pageid) - Tamanho do artigo em bytes (
size) - Idioma da edição (
lang) - Wikidata ID (
wikidata) - Data/hora da última revisão (
timestamp) - ID da revisão (
revid) - Lista de categorias (
categories) - Versões de idiomas do artigo (
langlinks: lang, title, link) - JSON bruto da resposta da API (
data)
Recursos
- Processamento de links desktop, mobile e
index.phpda Wikipedia - Formato de consulta curto
lang:title - Acompanhamento automático de redirecionamentos
- Plain text completo do artigo (sem HTML/Markdown)
- Categorias e links de idiomas com limite da API
max(até 500) - Suporte a proxy e configurações gerais do A-Parser
Casos de uso
- Extração de textos de artigos para NLP, RAG e bases de conhecimento
- Coleta de descrições e imagens para cards e bots
- Obtenção de categorias e versões de idiomas da página
- Enriquecimento dos resultados do SE::Wikipedia com o texto completo do artigo
Consultas
Formatos de consulta suportados:
- Link padrão:
https://en.wikipedia.org/wiki/Albert_Einstein
https://ru.wikipedia.org/wiki/Ефремов,_Иван_Антонович
- Link móvel:
https://en.m.wikipedia.org/wiki/Albert_Einstein
- Link do tipo
index.php:
https://en.wikipedia.org/w/index.php?title=Albert_Einstein
- Com âncora de seção (
#...é ignorado):
https://en.wikipedia.org/wiki/Albert_Einstein#Scientific_career
- Formato curto
lang:title:
en:Albert Einstein
pt-BR:Efremov, Ivan Antonovich
eo:Esperanto
Também são processados corretamente URL-encoding, _ no título, redirecionamentos e códigos de idiomas com hífen (be-tarask).
Opções de saída de resultados
O A-Parser suporta formatação flexível de resultados graças ao motor de modelos integrado Template Toolkit, o que permite exibir resultados em forma livre, bem como em formatos estruturados como CSV ou JSON.
Saída padrão
Formato do resultado:
$link\n$title\n$description\n$text\n
Exemplo de resultado:
https://en.wikipedia.org/wiki/Albert_Einstein
Albert Einstein
German-born theoretical physicist (1879–1955)
Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist best known for developing the theory of relativity. Einstein also made important contributions to quantum theory. His mass–energy equivalence formula E = mc2, which arises from special relativity, has been called "the world's most famous equation". He received the 1921 Nobel Prize in Physics for "his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect".
Born as a subject to the Kingdom of Württemberg, part of the German Empire, Einstein moved to Switzerland in 1895, forsaking his citizenship the following year. In 1896, at the age of seventeen, he enrolled in the mathematics and physics teaching diploma program at the Swiss federal polytechnic school in Zurich, graduating in 1900. He acquired Swiss citizenship a year later, which he kept for the rest of his life, and afterwards secured a permanent position at the Swiss Patent Office in Bern. In 1905, he submitted a successful PhD dissertation to the University of Zurich. In 1914, he moved to Berlin to join the Prussian Academy of Sciences and the Humboldt University of Berlin, becoming director of the Kaiser Wilhelm Institute for Physics in 1917; he also became a Prussian and consequently also German citizen again. In 1933, while Einstein was visiting the United States, Adolf Hitler came to power in Germany. Horrified by the Nazi persecution of his fellow Jews, he decided to remain in the US, and was granted American citizenship in 1940. On the eve of World War II, he endorsed a letter to President Franklin D. Roosevelt alerting him to the potential German nuclear weapons program and recommending that the US begin similar research, later carried out as the Manhattan Project.
...
Título + descrição + link
Formato do resultado:
$title\t$description\t$link\n
Exemplo de resultado:
Albert Einstein German-born theoretical physicist (1879–1955) https://en.wikipedia.org/wiki/Albert_Einstein
Saída em CSV
Formato do resultado:
[% tools.CSVline(title, description, link, pageid, wikidata, lang, size) %]
Texto inicial:
Título,Descrição,Link,Page ID,Wikidata,Idioma,Tamanho
Exemplo de resultado:
"Albert Einstein","German-born theoretical physicist (1879–1955)",https://en.wikipedia.org/wiki/Albert_Einstein,736,Q937,en,238698
Categorias
Formato do resultado:
$categories.format('$name\n')
Exemplo de resultado:
1879 births
1955 deaths
19th-century American Jews
19th-century German Jews
19th-century Swiss Jews
20th-century American engineers
20th-century American inventors
20th-century American letter writers
20th-century American male writers
20th-century American physicists
Versões de idiomas
Formato do resultado:
$langlinks.format('$lang\t$title\t$link\n')
Exemplo de resultado:
ab Einstein, Albert https://ab.wikipedia.org/wiki/%D0%95%D0%B8%D0%BD%D1%88%D1%82%D0%B5%D0%B8%D0%BD,_%D0%90%D0%BB%D0%B1%D0%B5%D1%80%D1%82
af Albert Einstein https://af.wikipedia.org/wiki/Albert_Einstein
gsw Albert Einstein https://als.wikipedia.org/wiki/Albert_Einstein
am አልበርት አይንስታይን https://am.wikipedia.org/wiki/%E1%8A%A0%E1%88%8D%E1%89%A0%E1%88%AD%E1%89%B5_%E1%8A%A0%E1%8B%AD%E1%8A%95%E1%88%B5%E1%89%B3%E1%8B%AD%E1%8A%95
de Albert Einstein https://de.wikipedia.org/wiki/Albert_Einstein
ru Einstein, Albert https://ru.wikipedia.org/wiki/%D0%AD%D0%B9%D0%BD%D1%88%D1%82%D0%B5%D0%B9%D0%BD,_%D0%90%D0%BB%D1%8C%D0%B1%D0%B5%D1%80%D1%82
Dump em JSON
Formato do resultado:
[%
obj = {};
obj.title = title;
obj.description = description;
obj.link = link;
obj.pageid = pageid;
obj.wikidata = wikidata;
obj.lang = lang;
obj.json _ "\n"
%]
Exemplo de resultado:
{"wikidata":"Q937","link":"https://en.wikipedia.org/wiki/Albert_Einstein","lang":"en","pageid":"736","title":"Albert Einstein","description":"German-born theoretical physicist (1879–1955)"}
Configurações possíveis
O scraper não possui opções exclusivas na UI: o idioma e o título são extraídos da consulta. São utilizadas apenas as configurações gerais (proxies, tentativas, etc.).