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

  • 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
  • Package and publish to PyPI
  • 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.1.0.tar.gz (9.0 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.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pywikiscrape-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ade88341a7c551a1312642ad50db35dcf9c7e47a2ad7d3c31c1dd51d8232ee55
MD5 230f147ccfa11e578ac0e03fd3254e02
BLAKE2b-256 b79bf1df0665983785b2b51ccf7b678cf5f32e489de2d371e9c8fef4003d3ef1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywikiscrape-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: pywikiscrape-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7da4ff67f9c7e592921eeff4454ed7c17190ad57dc33f544e08f50a8549aebd5
MD5 7a3340afe2f33911691fbb1e5871492a
BLAKE2b-256 a7d18dd1ef8ac016078d7b74466ce19910ddcc8be5300daf77d5bdd5f7746cba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywikiscrape-0.1.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

0.2.0

2 files

This release

0.1.0 This release

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