Skip to main content

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.

PyPI - Version PyPI - Python Versions PyPI - License

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.

Known Limitations

Some pages generate server-side HTML rather than client-side rendering a JSON response. These pages are currently unsupported but may be supported in the future. UnsupportedOperation will be raised for such pages.

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

MIT

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

mcmaster_scraper-0.2.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

mcmaster_scraper-0.2.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mcmaster_scraper-0.2.1.tar.gz.

File metadata

  • Download URL: mcmaster_scraper-0.2.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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

Hashes for mcmaster_scraper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3d2c30a2decc89d203b111b847cfc3d27d2ead31291373bbadc470a4d61b059e
MD5 a43aaaaedcee018ba8d43ca7626e919e
BLAKE2b-256 6f5728cb31b62d52237d9f76dc1065ca2961fd68d88e633f8fff0597010ad947

See more details on using hashes here.

File details

Details for the file mcmaster_scraper-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: mcmaster_scraper-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","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

Hashes for mcmaster_scraper-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9018ad66358b565d83f0eba84a5bc137b761092286470ac62c5941b4f771ddb
MD5 b6c9a6f9b6692f50fc780514c2a6036c
BLAKE2b-256 9c0ee157f360209a2f0656d5aca5a627d4e92bf6e86ecf48982025ca52052349

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page