Ga naar de hoofdinhoud

SE::Wikipedia::Article - scraper voor Wikipedia-artikelen

Overzicht van de scraper

Scraper voor Wikipedia-artikelen. Als invoer wordt een link naar een artikel opgegeven (of het korte formaat lang:title), als uitvoer — de volledige tekst van het artikel in plain text, een korte beschrijving, de canonieke link, thumbnail en originele afbeelding, categorieën, taalversies, Wikidata ID en metadata van de revisie.

Gegevens worden verkregen via de officiële MediaWiki Action API (prop=extracts|info|pageimages|...). De taal wordt bepaald op basis van de URL of het voorvoegsel van de query. Wikipedia-redirects worden automatisch verwerkt (bijvoorbeeld USAUnited States).

Gebruik de scraper SE::Wikipedia om artikelen op trefwoord te zoeken.

De functionaliteit van A-Parser maakt het mogelijk om instellingen voor gegevensextractie op te slaan voor toekomstig gebruik (presets), schema's voor gegevensextractie in te stellen en nog veel meer. Het opslaan van resultaten is mogelijk in de vorm en structuur die u nodig heeft, dankzij de ingebouwde krachtige sjabloon-engine Template Toolkit.

Verzamelde gegevens

Gegevens worden verzameld via de API https://{lang}.wikipedia.org/w/api.php.

  • Artikeltitel (title)
  • Korte beschrijving (description)
  • Volledige tekst van het artikel in plain text (text)
  • Canonieke link (link)
  • Voorbeeldweergave van afbeelding (thumb)
  • Originele afbeelding (image)
  • Page ID (pageid)
  • Artikelgrootte in bytes (size)
  • Taal van de editie (lang)
  • Wikidata ID (wikidata)
  • Tijdstip van de laatste revisie (timestamp)
  • Revisie-ID (revid)
  • Lijst met categorieën (categories)
  • Taalversies van het artikel (langlinks: lang, title, link)
  • Ruwe JSON van het API-antwoord (data)

Mogelijkheden

  • Verwerking van desktop-, mobiele en index.php-links van Wikipedia
  • Kort queryformaat lang:title
  • Automatisch volgen van redirects
  • Volledige plain text van het artikel (zonder HTML/Markdown)
  • Categorieën en taallinks met de API-limiet max (tot 500)
  • Ondersteuning voor proxy's en algemene instellingen van A-Parser

Toepassingen

  • Export van artikelteksten voor NLP, RAG en kennisbanken
  • Verzamelen van beschrijvingen en afbeeldingen voor kaarten en bots
  • Verkrijgen van categorieën en taalversies van een pagina
  • Verrijken van de resultaten van SE::Wikipedia met de volledige artikeltekst

Query's

Ondersteunde queryformaten:

  1. Standaard link:
https://en.wikipedia.org/wiki/Albert_Einstein
https://ru.wikipedia.org/wiki/Ефремов,_Иван_Антонович
  1. Mobiele link:
https://en.m.wikipedia.org/wiki/Albert_Einstein
  1. Link van het type index.php:
https://en.wikipedia.org/w/index.php?title=Albert_Einstein
  1. Met sectie-anker (#... wordt genegeerd):
https://en.wikipedia.org/wiki/Albert_Einstein#Scientific_career
  1. Kort formaat lang:title:
en:Albert Einstein
nl:Jefremov, Ivan Antonovitsj
eo:Esperanto

Ook URL-encoding, _ in de titel, redirects en taalcodes met een koppelteken (be-tarask) worden correct verwerkt.

Voorbeelden van resultaatuitvoer

A-Parser ondersteunt flexibele formattering van resultaten dankzij de ingebouwde sjabloon-engine Template Toolkit, waardoor resultaten in willekeurige vorm kunnen worden uitgevoerd, evenals in gestructureerde formaten zoals CSV of JSON.

Standaarduitvoer

Resultaatformaat:

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

Voorbeeld van resultaat:

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

Resultaatformaat:

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

Voorbeeld van resultaat:

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

Uitvoer naar CSV

Resultaatformaat:

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

Koptekst:

Titel,Beschrijving,Link,Page ID,Wikidata,Taal,Grootte

Voorbeeld van resultaat:

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

Categorieën

Resultaatformaat:

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

Voorbeeld van resultaat:

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

Resultaatformaat:

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

Voorbeeld van resultaat:

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 naar JSON

Resultaatformaat:

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

Voorbeeld van resultaat:

{"wikidata":"Q937","link":"https://en.wikipedia.org/wiki/Albert_Einstein","lang":"en","pageid":"736","title":"Albert Einstein","description":"German-born theoretical physicist (1879–1955)"}

Mogelijke instellingen

De scraper heeft geen unieke opties in de UI: taal en titel worden uit de query gehaald. Alleen algemene instellingen worden gebruikt (proxy's, retries, enz.).