Skip to main content

CC BY 4.0 Downloads

wikiscraper

Easy scraper that extracts data from Wikipedia articles thanks to its URL slug : title, images, summary, sections paragraphs, sidebar info

Developed by Alexandre MEYER

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0

Installation

$ pip install wikiscraper

Initialization

Import

import wikiscraper as ws

Main request

# Set the language page in Wikipedia for the query
# (ISO 639-1 & by default "en" for English)
ws.lang("fr")
# Search and get content by the URL slug of the article
# (Example : https://fr.wikipedia.org/wiki/Paris)
result = ws.searchBySlug("Paris")

Examples

Title H1 & URL

# Get article's title
result.getTitle()
# Get article's URL
result.getURL()

Sidebar

# Get value of the sidebar information label
result.getSideInfo("Gentilé")

Abstract

# Get all paragraphs of abstract
print(result.getAbstract())
# Get the second paragraph of abstract
print(result.getAbstract()[1])
# Optional : Get the x paragraphs, starting from the beginning
print(result.getAbstract(2))

Images

# Get all illustration images
img = result.getImage()
# Get a specific image thanks to its position in the page
print(img[0]) # Main image

Sections

# Get table of contents
# Only first headlines
print(result.getContentsTable())
# All headelines (first and second levels)
print(result.getContentsTable(subcontents=True))
# Get paragraphs from a specific section thanks to the parents' header title
# All optional args : .getSection(h2Title, h3Title, h4Title)
# Exemple : https://fr.wikipedia.org/wiki/Paris#Politique_et_administration
print(result.getSection('Politique et administration', 'Statut et organisation administrative', 'Historique')[0])

Errors

"Unable to find the requested query: please check the spelling of the slug"

  • Check if the spelling of the slug is correct
  • Check if the article exists
  • Check if the language set for the query matches with the slug (by default the search is for English articles)

Versions

  • 1.1.0 = Error Handling
  • 1.0.0 = init

Metadata

Release files for wikiscraper 1.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wikiscraper 1.1.9
File Size Uploaded Provenance
wikiscraper-1.1.9.tar.gz 10.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wikiscraper 1.1.9
File Interpreter ABI Platform
wikiscraper-1.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / wikiscraper-1.1.9.tar.gz

Download URL wikiscraper-1.1.9.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9790c6a07e1b36f4579aeb46adbf013a067365b4e14d29f5edcaddc9b714318a
BLAKE2b-256 checksum
How to use checksums
61063b996e96e8400f84d8d1e075b41ae5917fbfeab087ba931820bf744b4396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / wikiscraper-1.1.9-py3-none-any.whl

Download URL wikiscraper-1.1.9-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c1847ef6d62fe33dda762398c2121ebfba338f4bb94491be1b8eaaa7c772efa
BLAKE2b-256 checksum
How to use checksums
452ddcd1498fa900a97d8b0800b94cb0dacef96e3ec1663aa6d61789831e7898
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Security for wikiscraper 1.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page