SE::Wikipedia::Article - scraper d'articles Wikipedia
Présentation du scraper
Scraper d'articles Wikipedia. Une URL d'article (ou le format court lang:title) est fournie en entrée, et en sortie vous obtenez le texte intégral de l'article en texte brut, une brève description, le lien canonique, la vignette et l'image originale, les catégories, les versions linguistiques, l'ID Wikidata et les métadonnées de révision.
Les données sont obtenues via l'officiel MediaWiki Action API (prop=extracts|info|pageimages|...). La langue est déterminée à partir de l'URL ou du préfixe de la requête. Les redirections Wikipedia sont traitées automatiquement (par exemple, USA → United States).
Pour rechercher des articles par mots-clés, utilisez le scraper SE::Wikipedia.
La fonctionnalité d'A-Parser permet de sauvegarder les paramètres de collecte de données pour une utilisation ultérieure (présélections), de définir un calendrier de collecte de données et bien plus encore. La conservation des résultats est possible sous la forme et la structure dont vous avez besoin, grâce au puissant moteur de gabarits intégré Template Toolkit.
Données collectées
Les données sont collectées via l'API https://{lang}.wikipedia.org/w/api.php.
- Titre de l'article (
title) - Brève description (
description) - Texte intégral de l'article en texte brut (
text) - Lien canonique (
link) - Aperçu de l'image (
thumb) - Image originale (
image) - Page ID (
pageid) - Taille de l'article en octets (
size) - Langue de l'édition (
lang) - Wikidata ID (
wikidata) - Heure de la dernière révision (
timestamp) - ID de révision (
revid) - Liste des catégories (
categories) - Versions linguistiques de l'article (
langlinks: lang, title, link) - Réponse JSON brute de l'API (
data)
Possibilités
- Analyse des liens Wikipedia desktop, mobile et
index.php - Format de requête court
lang:title - Suivi automatique des redirections
- Texte brut complet de l'article (sans HTML/Markdown)
- Catégories et liens linguistiques avec la limite API
max(jusqu'à 500) - Prise en charge des proxys et des paramètres généraux d'A-Parser
Cas d'utilisation
- Extraction de textes d'articles pour le NLP, le RAG et les bases de connaissances
- Collecte de descriptions et d'images pour des fiches et des bots
- Obtention des catégories et des versions linguistiques d'une page
- Enrichissement des résultats de SE::Wikipedia avec le texte intégral de l'article
Requêtes
Formats de requêtes pris en charge :
- Lien standard :
https://en.wikipedia.org/wiki/Albert_Einstein
https://ru.wikipedia.org/wiki/Ефремов,_Иван_Антонович
- Lien mobile :
https://en.m.wikipedia.org/wiki/Albert_Einstein
- Lien de type
index.php:
https://en.wikipedia.org/w/index.php?title=Albert_Einstein
- Avec ancre de section (
#...est ignoré) :
https://en.wikipedia.org/wiki/Albert_Einstein#Scientific_career
- Format court
lang:title:
en:Albert Einstein
fr:Efremov, Ivan Antonovitch
eo:Esperanto
L'encodage d'URL, les _ dans le titre, les redirections et les codes de langue avec trait d'union (be-tarask) sont également correctement traités.
Variantes de sortie des résultats
A-Parser prend en charge un formatage flexible des résultats grâce au moteur de gabarits intégré Template Toolkit, ce qui lui permet de sortir les résultats sous n'importe quelle forme, ainsi que dans des formats structurés tels que CSV ou JSON.
Sortie par défaut
Format du résultat :
$link\n$title\n$description\n$text\n
Exemple de résultat :
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.
...
Titre + description + lien
Format du résultat :
$title\t$description\t$link\n
Exemple de résultat :
Albert Einstein German-born theoretical physicist (1879–1955) https://en.wikipedia.org/wiki/Albert_Einstein
Sortie en CSV
Format du résultat :
[% tools.CSVline(title, description, link, pageid, wikidata, lang, size) %]
Texte initial :
Titre,Description,Lien,Page ID,Wikidata,Langue,Taille
Exemple de résultat :
"Albert Einstein","German-born theoretical physicist (1879–1955)",https://en.wikipedia.org/wiki/Albert_Einstein,736,Q937,en,238698
Catégories
Format du résultat :
$categories.format('$name\n')
Exemple de résultat :
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
Versions linguistiques
Format du résultat :
$langlinks.format('$lang\t$title\t$link\n')
Exemple de résultat :
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 en JSON
Format du résultat :
[%
obj = {};
obj.title = title;
obj.description = description;
obj.link = link;
obj.pageid = pageid;
obj.wikidata = wikidata;
obj.lang = lang;
obj.json _ "\n"
%]
Exemple de résultat :
{"wikidata":"Q937","link":"https://en.wikipedia.org/wiki/Albert_Einstein","lang":"en","pageid":"736","title":"Albert Einstein","description":"German-born theoretical physicist (1879–1955)"}
Paramètres possibles
Le scraper n'a pas d'options uniques dans l'interface utilisateur : la langue et le titre sont extraits de la requête. Seuls les paramètres communs sont utilisés (proxys, tentatives, etc.).