Fetch product tables from a McMaster-Carr URL as a DataFrame for complex filtering and calculations
Project description
McMaster-Scraper
A Python library for fetching product tables from a McMaster-Carr URL as a DataFrame for complex filtering and calculations.
Features
- Caches data locally to speed up future calls
- Supports both sync/async APIs
- Works in Python files and Jupyter notebooks
- Includes convenience functions to quickly retrieve product tables from multiple URLs
- Typed functions for type-checking compatibility
Install
McMaster-Scraper is available on PyPi:
pip install mcmaster-scraper
McMaster-Scraper requires Playwright to fetch the product tables. It is already included as a dependency. However, you will need to install the browsers manually:
playwright install
Quick Start
To use the Sync API, import the sync_api module and call get_products_from_url(s):
from mcmaster_scraper.sync_api import get_products_from_url
url = "https://www.mcmaster.com/products/screws/socket-head-screws-2~/steel-socket-head-screws~~/"
data = get_products_from_url(url) # Returns a DataFrame with all the products from the URL
... # Do stuff with the DataFrame (filter, perform calculations, etc.)
Using the Async API is similar, import the async_api module and await the function call:
from mcmaster_scraper.async_api import get_products_from_url
url = "https://www.mcmaster.com/products/screws/socket-head-screws-2~/steel-socket-head-screws~~/"
data = await get_products_from_url(url) # Returns a DataFrame with all the products from the URL
... # Do stuff with the DataFrame (filter, perform calculations, etc.)
Docs
API Reference
The API reference can be found on GitHub Pages.
Examples
An example script can be found in docs/example.py.
Disclaimer
This library is for responsible data extraction only. Do not:
- Scrape beyond reasonable rates
- Violate Terms of Service
- Circumvent access controls
- Use data for unauthorized commercial purposes
Legal Notice
This library is provided as-is. Authors are not liable for any legal, technical, or business consequences resulting from misuse of this library. Users assume full responsibility for compliance with applicable laws, regulations, and website policies.
By using this library, you acknowledge and agree to these responsibilities.
License
Project details
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 mcmaster_scraper-0.1.0.tar.gz.
File metadata
- Download URL: mcmaster_scraper-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
391271d37c95d8058972272be48e687288378379dce243c444a859a2e30f31ac
|
|
| MD5 |
8e697dab4be43deb12a2b5c0c845a8ba
|
|
| BLAKE2b-256 |
614c1a7afc496d39a30ade828d38a2c7c524110d9a06e9df8257c3004040f6d1
|
File details
Details for the file mcmaster_scraper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcmaster_scraper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
844ad994b83d1fb0f2688b5c1418715e90e295343685758d8daad7e4be0f9b02
|
|
| MD5 |
a59a5045372da715c7ed0d2bfc1578e8
|
|
| BLAKE2b-256 |
4c2c56e92ba19a4f3995f9c44cfbce968b56c0cb24cefb0d1bc2744b09a7b65a
|