|
| 1 | +# Steam Market Scraper Parser |
| 2 | +<p> |
| 3 | + <a |
| 4 | + href='https://github.com/RandomProgramm3r/Steam-Market-Scraper/actions/workflows/lint.yml/'> |
| 5 | + <img |
| 6 | + src='https://github.com/RandomProgramm3r/Steam-Market-Scraper/actions/workflows/lint.yml/badge.svg' |
| 7 | + alt='pipeline status' |
| 8 | + height='30' |
| 9 | + width='30'> |
| 10 | + </a> |
| 11 | + <a |
| 12 | + href='https://steamcommunity.com/market/'> |
| 13 | + <img |
| 14 | + src='https://steamcommunity.com/favicon.ico' |
| 15 | + alt='Steam logo' |
| 16 | + height='30' |
| 17 | + width='30'> |
| 18 | + </a> |
| 19 | +</p> |
| 20 | + |
| 21 | + |
| 22 | +## TOC |
| 23 | + |
| 24 | +- [📋 Description](#-description) |
| 25 | +- [💻 Requirements](#-requirements) |
| 26 | +- [🚀 Project Installation](#-project-installation) |
| 27 | + - [📂 Step 1: Clone the Repository](#-step-1-clone-the-repository) |
| 28 | + - [🖥 Step 2: Create and activate a virtual environment](#-step-2-create-and-activate-a-virtual-environment) |
| 29 | + - [🔃 Step 3: Installing Dependencies](#-step-3-installing-dependencies) |
| 30 | + - [🛠️ Dependencies for development (dev)](#%EF%B8%8F-dependencies-for-development-dev) |
| 31 | +- [⚙ Linters](#-linters) |
| 32 | +- [🧩 Usage](#-usage) |
| 33 | +- [🔨 Function Signature](#-function-signature) |
| 34 | +- [📤 Example](#-example) |
| 35 | + |
| 36 | + |
| 37 | +## 📋 Description |
| 38 | + |
| 39 | +This project is a parser for the steam market of such games as CS 2, Team Fortress 2, Dota 2, PUBG, RUST, etc. |
| 40 | + |
| 41 | + |
| 42 | +This guide describes the steps to install and run the project on Linux and Windows. |
| 43 | + |
| 44 | + |
| 45 | +## 💻 Requirements |
| 46 | + |
| 47 | +Before you start, make sure that the following components are installed on your system: |
| 48 | + |
| 49 | +- **Python 3** (check with `python3 --version` Linux / `python --version` Windows) |
| 50 | +#### I'm using Python 3.13. Other versions will probably work. |
| 51 | +- **pip** (check with `pip --version`) |
| 52 | +- **Git** (check with `git --version`) |
| 53 | +- **Python Virtual Environment** (venv) |
| 54 | +- **Linux Shell** (for example, Bash) |
| 55 | + |
| 56 | +## 🚀 Project Installation |
| 57 | + |
| 58 | +### 📂 Step 1: Clone the Repository |
| 59 | + |
| 60 | +Clone the project repository using Git: |
| 61 | + |
| 62 | +```bash |
| 63 | +git clone url--------------------------------------- |
| 64 | +cd team ????????????????????????????? |
| 65 | +``` |
| 66 | + |
| 67 | +### 🖥 Step 2: Create and activate a virtual environment |
| 68 | + |
| 69 | +Create a virtual environment using the `venv` command, which allows you to isolate project dependencies: |
| 70 | + |
| 71 | +```bash |
| 72 | +python3 -m venv venv # Linux |
| 73 | +python -m venv venv # Windows |
| 74 | +``` |
| 75 | + |
| 76 | +Activate the virtual environment: |
| 77 | + |
| 78 | +```bash |
| 79 | +source venv/bin/activate # Linux |
| 80 | +source venv/Scripts/activate # Windows |
| 81 | +``` |
| 82 | + |
| 83 | +### 🔃 Step 3: Installing Dependencies |
| 84 | + |
| 85 | +Dependencies are divided into two groups: |
| 86 | + |
| 87 | +- **For development (dev)** – additional dependencies for development. |
| 88 | +- **For code analysis (flake8)** – additional dependencies for code analysis. |
| 89 | + |
| 90 | +#### 🛠️ Dependencies for development (dev) |
| 91 | + |
| 92 | +Install the dependencies for local development (they include all **flake8** dependencies) |
| 93 | + |
| 94 | +```bash |
| 95 | +pip install -r requirements/dev.txt |
| 96 | +``` |
| 97 | + |
| 98 | +Now you can use the parser. |
| 99 | + |
| 100 | + |
| 101 | +## ⚙ Linters |
| 102 | + |
| 103 | +If there are any changes, I recommend using linters: |
| 104 | + |
| 105 | +```bash |
| 106 | +flake8 . --count --show-source --statistics # Use to view PEP8 errors. |
| 107 | +black . --check --verbose -- # Use to format code. |
| 108 | +isort . --verbose # Use to format the order of imports. |
| 109 | +``` |
| 110 | + |
| 111 | + |
| 112 | +## 🧩 Usage |
| 113 | +##### A market_scraper function retrieves pricing information for a specified item from the Steam Community Market. |
| 114 | +##### It constructs the request URL using the item name, Steam application ID, and the desired currency, the fetches and decodes the JSON response. |
| 115 | + |
| 116 | +##### the list of all available currencies is stored in data.py, as well as a list with some games from steam. (you can add your own games) |
| 117 | + |
| 118 | +## 🔨 Function Signature |
| 119 | +```python |
| 120 | +import data |
| 121 | +def market_scraper( |
| 122 | + item_name: str, |
| 123 | + app_id: int, |
| 124 | + currency: int = data.Currency.USD.value, |
| 125 | +) -> str: |
| 126 | + pass |
| 127 | +``` |
| 128 | + |
| 129 | +#### Parameters: |
| 130 | +##### item_name (str): Full name of the item. |
| 131 | +##### app_id (int): Steam Application ID. |
| 132 | +##### currency (int, optional): Currency code (default: USD). |
| 133 | + |
| 134 | +#### Returns: |
| 135 | +##### A dictionary with the JSON response or a string with an error message. |
| 136 | + |
| 137 | + |
| 138 | +## 📤 Example |
| 139 | + |
| 140 | +```python |
| 141 | +import data |
| 142 | +import scraper |
| 143 | + |
| 144 | +# Example usage: Fetch price information for 'Dreams & Nightmares Case' in USD for the CS2 app. |
| 145 | +# see more in examples.py |
| 146 | +print( |
| 147 | + scraper.market_scraper( |
| 148 | + 'Dreams & Nightmares Case', |
| 149 | + data.Apps.CS2.value, |
| 150 | + data.Currency.USD.value, |
| 151 | + ), |
| 152 | +) |
| 153 | +``` |
| 154 | +#### Output json data: |
| 155 | +```json |
| 156 | +{ |
| 157 | + "success": true, |
| 158 | + "lowest_price": "$1.90", |
| 159 | + "volume": "77,555", |
| 160 | + "median_price": "$1.90" |
| 161 | +} |
| 162 | +``` |
0 commit comments