Ir al contenido principal

SE::Wikipedia::Article - extractor de artículos de Wikipedia

Resumen del extractor

Extractor de artículos de Wikipedia. Se ingresa un enlace al artículo (o el formato corto lang:title), y el resultado es el texto completo del artículo en plain text, una descripción breve, el enlace canónico, miniatura e imagen original, categorías, versiones de idiomas, Wikidata ID y metadatos de la revisión.

Los datos se obtienen a través de la MediaWiki Action API oficial (prop=extracts|info|pageimages|...). El idioma se determina a partir de la URL o del prefijo de la consulta. Las redirecciones de Wikipedia se procesan automáticamente (por ejemplo, USAUnited States).

Para buscar artículos por palabras clave, utilice el extractor SE::Wikipedia.

La funcionalidad de A-Parser permite guardar la configuración de la extracción de datos para su uso posterior (ajustes preestablecidos), programar tareas de extracción y mucho más. Es posible guardar los resultados en el formato y la estructura que necesite, gracias al potente motor de plantillas integrado Template Toolkit.

Datos recopilados

Los datos se recopilan a través de la API https://{lang}.wikipedia.org/w/api.php.

  • Título del artículo (title)
  • Descripción breve (description)
  • Texto completo del artículo en plain text (text)
  • Enlace canónico (link)
  • Vista previa de la imagen (thumb)
  • Imagen original (image)
  • Page ID (pageid)
  • Tamaño del artículo en bytes (size)
  • Idioma de la edición (lang)
  • Wikidata ID (wikidata)
  • Hora de la última revisión (timestamp)
  • ID de la revisión (revid)
  • Lista de categorías (categories)
  • Versiones de idioma del artículo (langlinks: lang, title, link)
  • JSON bruto de la respuesta de la API (data)

Capacidades

  • Análisis de enlaces de Wikipedia de escritorio, móviles y index.php
  • Formato de consulta corto lang:title
  • Seguimiento automático de redirecciones
  • Texto plano completo del artículo (sin HTML/Markdown)
  • Categorías y enlaces de idiomas con el límite de API max (hasta 500)
  • Soporte para proxy y configuraciones generales de A-Parser

Casos de uso

  • Descarga de textos de artículos para NLP, RAG y bases de conocimiento
  • Recopilación de descripciones e imágenes para fichas y bots
  • Obtención de categorías y versiones de idiomas de la página
  • Enriquecimiento de los resultados de SE::Wikipedia con el texto completo del artículo

Consultas

Formatos de consulta admitidos:

  1. Enlace estándar:
https://en.wikipedia.org/wiki/Albert_Einstein
https://ru.wikipedia.org/wiki/Ефремов,_Иван_Антонович
  1. Enlace móvil:
https://en.m.wikipedia.org/wiki/Albert_Einstein
  1. Enlace tipo index.php:
https://en.wikipedia.org/w/index.php?title=Albert_Einstein
  1. Con ancla de sección (#... se ignora):
https://en.wikipedia.org/wiki/Albert_Einstein#Scientific_career
  1. Formato corto lang:title:
en:Albert Einstein
es:Efremov, Iván Antónovich
eo:Esperanto

También se procesan correctamente el URL-encoding, los _ en el título, las redirecciones y los códigos de idioma con guion (be-tarask).

Variantes de salida de resultados

A-Parser admite un formateo flexible de los resultados gracias al motor de plantillas integrado Template Toolkit, lo que le permite mostrar los resultados en forma libre, así como en forma estructurada, por ejemplo CSV o JSON.

Salida por defecto

Formato del resultado:

$link\n$title\n$description\n$text\n

Ejemplo 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.
...

Formato del resultado:

$title\t$description\t$link\n

Ejemplo de resultado:

Albert Einstein German-born theoretical physicist (1879–1955)   https://en.wikipedia.org/wiki/Albert_Einstein

Salida en CSV

Formato del resultado:

[% tools.CSVline(title, description, link, pageid, wikidata, lang, size) %]

Texto inicial:

Título,Descripción,Enlace,Page ID,Wikidata,Idioma,Tamaño

Ejemplo de resultado:

"Albert Einstein","German-born theoretical physicist (1879–1955)",https://en.wikipedia.org/wiki/Albert_Einstein,736,Q937,en,238698

Categorías

Formato del resultado:

$categories.format('$name\n')

Ejemplo 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

Formato del resultado:

$langlinks.format('$lang\t$title\t$link\n')

Ejemplo 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

Volcado en JSON

Formato del resultado:

[%
obj = {};
obj.title = title;
obj.description = description;
obj.link = link;
obj.pageid = pageid;
obj.wikidata = wikidata;
obj.lang = lang;
obj.json _ "\n"
%]

Ejemplo 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)"}

Configuraciones posibles

El extractor no tiene opciones únicas en la interfaz de usuario: el idioma y el título se toman de la consulta. Solo se utilizan las configuraciones comunes (proxies, reintentos, etc.).