Metadata-Version: 2.4
Name: mcmaster-scraper
Version: 0.2.0
Summary: Fetch product tables from a McMaster-Carr URL as a DataFrame for complex filtering and calculations
Keywords: mcmaster,mcmaster-carr,scraper,extractor,parser,fetcher,part,catalog,product
Author: Alex
Author-email: Alex <thedjchidev@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Manufacturing
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Requires-Dist: diskcache>=5.6.3
Requires-Dist: pandas>=2.3.3
Requires-Dist: platformdirs>=3.5.1
Requires-Dist: playwright>=1.14.0
Requires-Dist: playwright-stealth==2.0.3
Requires-Python: >=3.10
Project-URL: github, https://github.com/thedjchi/mcmaster-scraper
Description-Content-Type: text/markdown

# McMaster-Scraper

A Python library for fetching product tables from a [McMaster-Carr](https://www.mcmaster.com) URL
as a [DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) for complex filtering and
calculations.

![PyPI - Version](https://img.shields.io/pypi/v/mcmaster-scraper?style=for-the-badge)
![PyPI - Python Versions](https://img.shields.io/pypi/pyversions/mcmaster-scraper?style=for-the-badge)
![PyPI - License](https://img.shields.io/pypi/l/mcmaster-scraper?style=for-the-badge)

## 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](https://playwright.dev/python) 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](https://thedjchi.github.io/mcmaster-scraper/mcmaster_scraper.html).

### Examples

An example script can be found
in [docs/example.py](https://github.com/thedjchi/mcmaster-scraper/blob/master/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

[MIT](https://github.com/thedjchi/mcmaster-scraper/blob/master/LICENSE)