Spaces:
Sleeping
Sleeping
Download main.py from YoScratched/inventorytracker: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/spaces/YoScratched/inventorytracker/resolve/main/main.py
- Command line
-
hf download hf://spaces/YoScratched/inventorytracker/main.py
-
curl -L -o main.py https://huggingface.co/spaces/YoScratched/inventorytracker/resolve/main/main.py
1.77 kB
| """ | |
| main.py β Steam CS2 Inventory Scraper | |
| Usage: | |
| python main.py | |
| python main.py https://steamcommunity.com/profiles/<steamid>/inventory/ | |
| """ | |
| import sys | |
| from fetcher import fetch_inventory_from_site, convert_to_steamdt_url | |
| from parser import extract_and_enrich_items | |
| from reporter import print_inventory_summary | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # ENTRY POINT | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| DEFAULT_URL = "https://steamcommunity.com/profiles/76561198080075870/inventory/" | |
| def scrape_steam_inventory(steam_url: str) -> list[dict] | None: | |
| """ | |
| Full pipeline: | |
| 1. Convert Steam URL β SteamDT URL | |
| 2. Fetch raw API JSON via headless browser | |
| 3. Parse + enrich items | |
| 4. Print summary | |
| 5. Return item list | |
| """ | |
| steamdt_url = convert_to_steamdt_url(steam_url) | |
| print(f"Steam URL : {steam_url}") | |
| print(f"SteamDT URL: {steamdt_url}") | |
| raw_data = fetch_inventory_from_site(steamdt_url) | |
| if not raw_data: | |
| print("ERROR: No data received from SteamDT.") | |
| return None | |
| items = extract_and_enrich_items(raw_data) | |
| if not items: | |
| print("ERROR: No items found in API response.") | |
| return None | |
| print_inventory_summary(items) | |
| return items | |
| if __name__ == "__main__": | |
| url = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_URL | |
| scrape_steam_inventory(url) | |