Skip to main content

pywikiscrape

GitHub license GitHub issues Python Version

pywikiscrape is a user-friendly but powerful open-source Wikipedia scraper written in Python that lets users export articles to an SQLite3 database using Beautiful Soup.


Features

  • Automated Scraping: Automatically scrapes Wikipedia articles with requests and BeautifulSoup.
  • Zero-Config: Simply run the script, and it will handle everything for you.
  • Two SQLite3 Tables: Stores two tables, one for the content of the article, the other for the links contained in it, in one file.
  • Minimal Dependencies: Relying only on Python standard library modules, requests, and BeautifulSoup.
  • Error Handling: Handles HTTP error codes without user input.
  • Logging: Uses the Python Standard Library module logging over print statements.

Usage

Currently, the only way to use pywikiscrape is to clone the GitHub repository and manually run the script. To do so, follow this code block. You must ensure that you have all required dependencies available to your Python interpreter.

# Clone the repository
git clone https://github.com/tyleruploads/pywikiscrape.git
cd pywikiscrape

# Set up a virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Runs the script
python3 src/main.py

The script saves its output to an SQLite3 database with the name of pywikiscrape.db. You do not need to pass any arguments to the script.

To choose a seed, the script uses a few link-rich preset Wikipedia articles and one link to a completely random Wikipedia article.

Database Schemas

Table 1: Articles

This table contains the title of the Wikipedia article and the text inside of it.

Column Type Description
id INTEGER Primary Key
title TEXT Wikipedia article Title
text TEXT Content of Wikipedia article

Table 2: Links

This table contains the id correlating an article to its entry in table 1 and the links contained inside of it.

Column Type Description
id INTEGER Primary Key
links_json TEXT The links contained in the Wikipedia article

Roadmap

  • Package and publish to PyPI
  • Have the CLI ask the user for a seed, a custom path for the output database, and other settings, all with defaults the user can easily select
  • Support scraping non-English Wikipedia domains
  • Store more metadata about article like categories, images, and when it was added to the database
  • Allow more export options for data like JSON, CSV, or Parquet alongside SQLite
  • Add Unit testing
  • Add a Dockerfile and docker-compose.yml for zero-setup execution

Contributing

Contributions are what make open-source projects one of a kind. All contributions are highly appreciated.

  • Found a bug or issue: Open an Issue and show the output of the script, the steps to reproduce it, and as much information as possible
  • Have an idea: Open an Issue and explain your idea as much as possible, why you think it would be a good addition to the project, and any other important information.

License

This project is licensed under the MIT License - see the LICENSE file for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywikiscrape-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywikiscrape-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pywikiscrape-0.2.0.tar.gz.

File metadata

  • Download URL: pywikiscrape-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pywikiscrape-0.2.0.tar.gz
Algorithm Hash digest
SHA256 abea44dfe66dc106d3c25070a3a673fddf871a03fbecde2f868d0d84c11858d8
MD5 42ea5925d4adbfd4c4892ae4e0ad40c3
BLAKE2b-256 e2b11ea5ec4818cd44fbf51f99d076a7ea7cf87ea9b5e88b7599a567aa46f2e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywikiscrape-0.2.0.tar.gz:

Publisher: publish.yaml on tyleruploads/pywikiscrape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pywikiscrape-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pywikiscrape-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pywikiscrape-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67db183e6160396721e33802b27dab06e9cb55d2af8656294ac67c1b3a825cb2
MD5 0def856ac7ea4807e1d2851e216e0a89
BLAKE2b-256 02b4536cb948462b52f140b7db9a84bd190bf434c577ca75cff7e52ce95982fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywikiscrape-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on tyleruploads/pywikiscrape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

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