pywikiscrape
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
loggingover 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abea44dfe66dc106d3c25070a3a673fddf871a03fbecde2f868d0d84c11858d8
|
|
| MD5 |
42ea5925d4adbfd4c4892ae4e0ad40c3
|
|
| BLAKE2b-256 |
e2b11ea5ec4818cd44fbf51f99d076a7ea7cf87ea9b5e88b7599a567aa46f2e2
|
Provenance
The following attestation bundles were made for pywikiscrape-0.2.0.tar.gz:
Publisher:
publish.yaml on tyleruploads/pywikiscrape
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywikiscrape-0.2.0.tar.gz -
Subject digest:
abea44dfe66dc106d3c25070a3a673fddf871a03fbecde2f868d0d84c11858d8 - Sigstore transparency entry: 2593361380
- Sigstore integration time:
-
Permalink:
tyleruploads/pywikiscrape@1c833ac4914f0e7384799ad08d49f5c1c5f61f91 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tyleruploads
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1c833ac4914f0e7384799ad08d49f5c1c5f61f91 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67db183e6160396721e33802b27dab06e9cb55d2af8656294ac67c1b3a825cb2
|
|
| MD5 |
0def856ac7ea4807e1d2851e216e0a89
|
|
| BLAKE2b-256 |
02b4536cb948462b52f140b7db9a84bd190bf434c577ca75cff7e52ce95982fb
|
Provenance
The following attestation bundles were made for pywikiscrape-0.2.0-py3-none-any.whl:
Publisher:
publish.yaml on tyleruploads/pywikiscrape
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywikiscrape-0.2.0-py3-none-any.whl -
Subject digest:
67db183e6160396721e33802b27dab06e9cb55d2af8656294ac67c1b3a825cb2 - Sigstore transparency entry: 2593361506
- Sigstore integration time:
-
Permalink:
tyleruploads/pywikiscrape@1c833ac4914f0e7384799ad08d49f5c1c5f61f91 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tyleruploads
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1c833ac4914f0e7384799ad08d49f5c1c5f61f91 -
Trigger Event:
push
-
Statement type: