pywikiscrape
pywikiscrape is a user-friendly but powerful open-source Wikipedia scraper written in Python that lets users export articles in any language to an SQLite3 database using Beautiful Soup.
pywikiscrape now supports all Wikipedias, English and non-English, all with manual and automatic seeds
Features
- Automated Scraping: Automatically scrapes Wikipedia articles with requests and BeautifulSoup.
- Supports Non-English Wikipedias: Supports scraping for all English and non-English Wikipedias, along with automatic and manual seeds.
- Minimal-Config: Simply run the script, enter a couple of settings or click enter for defaults, and sit back and relax.
- 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 many types of errors on its own, and only asks for extra user input if necessary.
- Logging: Uses the Python Standard Library module
loggingover print statements.
Usage
Install with pip or pipx (recommended)
It is recommended for Linux and macOS users to use pipx rather than pip due to the high possibility of your Python being marked as externally managed in order to prevent the overwriting of files needed by your operating system, which can break system tools. Windows users are free to use pip or pipx to install pywikiscrape.
| Tool | Command |
|---|---|
| pip | pip install pywikiscrape |
| pipx | pipx install pywikiscrape |
Clone repository and manually run
If you wish to contribute to this project, you must clone this repository to your local machine, make your changes, and make a pull request. To do so, follow this code block. It is recommended for non-Windows users to use pipx instead of pip to install the dependencies, but either may be used if your operating system or distribution allows so.# 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
pipx install -r requirements.txt
# Runs the script
python3 src/main.py
The script saves its output to an SQLite3 database with the default name of LANGUAGE_CODE-pywikiscrape.db. All required variables are extracted from the user via text prompts. There are no arguments you need to pass to the program.
The seed can either be chosen manually by the user or automatically by the script.
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 Wikipedias
- 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.3.0.tar.gz.
File metadata
- Download URL: pywikiscrape-0.3.0.tar.gz
- Upload date:
- Size: 58.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f135f2325e4dc67f8d5e4edcf86195731e2f9a5d1fa5b65dcf57d7bde1e5ca
|
|
| MD5 |
248675f44f01b34fde0fa21abd82a6c4
|
|
| BLAKE2b-256 |
c3866182d6557cc98624d18bc097582346b93b6c3ea871aeacfc843cc44cf87d
|
Provenance
The following attestation bundles were made for pywikiscrape-0.3.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.3.0.tar.gz -
Subject digest:
31f135f2325e4dc67f8d5e4edcf86195731e2f9a5d1fa5b65dcf57d7bde1e5ca - Sigstore transparency entry: 2610321506
- Sigstore integration time:
-
Permalink:
tyleruploads/pywikiscrape@cd21a1e6c621bd78a6d0c9bffc7ced41db46d2c8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/tyleruploads
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@cd21a1e6c621bd78a6d0c9bffc7ced41db46d2c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pywikiscrape-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pywikiscrape-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.7 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 |
6048298950fa40c30927816b8faf2dd32458665d849bb2d839e327228b029969
|
|
| MD5 |
c936e462a0a27801aca6307823281a00
|
|
| BLAKE2b-256 |
1438788e049423c2e23ffb6f1fcdfb22c59d3cd9379769587954efa452a23899
|
Provenance
The following attestation bundles were made for pywikiscrape-0.3.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.3.0-py3-none-any.whl -
Subject digest:
6048298950fa40c30927816b8faf2dd32458665d849bb2d839e327228b029969 - Sigstore transparency entry: 2610321939
- Sigstore integration time:
-
Permalink:
tyleruploads/pywikiscrape@cd21a1e6c621bd78a6d0c9bffc7ced41db46d2c8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/tyleruploads
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@cd21a1e6c621bd78a6d0c9bffc7ced41db46d2c8 -
Trigger Event:
push
-
Statement type: