PFR SDK¶
Pro Football Reference HTML scraping client.
pfr
¶
AsyncScrapingBackend
¶
Bases: Protocol
Protocol for asynchronous HTML scraping backends.
Implementations must provide an async get_page_content method that
fetches a fully-rendered web page and returns its HTML as a string.
get_page_content
async
¶
Fetch a page's HTML content asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The full URL to fetch. |
required |
wait_for_element
|
str
|
CSS selector to wait for before extracting HTML. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The page's outer HTML as a string. |
Source code in src/griddy/pfr/backends.py
ScrapingBackend
¶
Bases: Protocol
Protocol for synchronous HTML scraping backends.
Implementations must provide a get_page_content method that
fetches a fully-rendered web page and returns its HTML as a string.
get_page_content
¶
Fetch a page's HTML content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The full URL to fetch. |
required |
wait_for_element
|
str
|
CSS selector to wait for before extracting HTML. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The page's outer HTML as a string. |
Source code in src/griddy/pfr/backends.py
GriddyPFR
¶
GriddyPFR(
pfr_auth=None,
server_idx=None,
server_url=None,
url_params=None,
client=None,
async_client=None,
retry_config=UNSET,
timeout_ms=None,
debug_logger=None,
browserless_config=None,
scraping_backend=None,
async_scraping_backend=None,
)
Bases: LazySubSDKMixin, BaseGriddySDK, BaseSDK
Main client for accessing Pro Football Reference data.
Sub-SDKs are loaded lazily on first access to minimize startup time.
Example
from griddy.pfr import GriddyPFR pfr = GriddyPFR() games = pfr.schedule.get_season_schedule(season=2015)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pfr_auth
|
Optional[Dict[str, str]]
|
Optional dictionary containing authentication information. PFR does not currently require auth, but this is available for future use. Example: {"accessToken": "your_token"} |
None
|
server_idx
|
Optional[int]
|
Index of the server to use from the server list. |
None
|
server_url
|
Optional[str]
|
Override the default server URL. |
None
|
url_params
|
Optional[Dict[str, str]]
|
Parameters to template into the server URL. |
None
|
client
|
Optional[HttpClient]
|
Custom synchronous HTTP client (must implement HttpClient). |
None
|
async_client
|
Optional[AsyncHttpClient]
|
Custom async HTTP client (must implement AsyncHttpClient). |
None
|
retry_config
|
OptionalNullable[RetryConfig]
|
Configuration for automatic request retries. |
UNSET
|
timeout_ms
|
Optional[int]
|
Request timeout in milliseconds. |
None
|
debug_logger
|
Optional[Logger]
|
Custom logger for debug output. |
None
|
browserless_config
|
Optional[BrowserlessConfig]
|
Configuration for Browserless API requests. Overrides default proxy, timeout, and TTL values. Ignored when a custom scraping_backend is provided. |
None
|
scraping_backend
|
Optional[ScrapingBackend]
|
A synchronous scraping backend that satisfies the
:class: |
None
|
async_scraping_backend
|
Optional[AsyncScrapingBackend]
|
An asynchronous scraping backend that
satisfies the :class: |
None
|
Source code in src/griddy/pfr/sdk.py
SDKConfiguration
dataclass
¶
SDKConfiguration(
client,
client_supplied,
async_client,
async_client_supplied,
debug_logger,
security=None,
server_url="",
server_idx=0,
language="python",
sdk_version=__version__,
user_agent=__user_agent__,
retry_config=(lambda: UNSET)(),
timeout_ms=None,
server_type="default",
scraping_backend=None,
async_scraping_backend=None,
)
Bases: SDKConfiguration
PFR-specific SDK configuration with server URL resolution.
get_server_details
¶
Return the base URL and params for the configured server type.