If you have ever tried to βscrapeβ a modern website, you know the pain: the UI looks simple, but the data is loaded dynamically, and the DOM changes every two minutes π
β‘ What this tool does
You set a threshold like 71.50 RUB.
The script checks the current best USDT/RUB buy offer and notifies you in Telegram if the price is below that level.
Core flow:
π§ open the Bybit P2P page
π΅οΈ listen to network responses
π§Ύ parse JSON from the P2P API response
π compare the best price with your threshold
π© send Telegram message
No fragile selectors. No DOM gymnastics. Just data.
π§° Setup
Install dependencies:
pip install -r requirements.txt
playwright install
Create .env:
BOT_TOKEN=your_telegram_bot_token
CHAT_ID=your_chat_id
Run:
python main.py
Then enter your threshold when the script asks for it.
π§ The key idea: intercept the JSON response
Bybit P2P UI is basically a shell. The real data is coming from an internal endpoint.
So the strategy is:
open the page
subscribe to Playwright response events
filter responses by URL (the internal API endpoint)
call response.json()
extract offers and prices
This is usually more stable than DOM scraping because you rely on the same payload the app uses internally.
π¦ Why network interception beats DOM scraping
DOM scraping often breaks because:
class names change
elements are lazy loaded
content is rendered differently by region or language
the site adds random wrappers
Network interception is cleaner:
β
data structure is consistent
β
you get structured JSON
β
fewer moving parts
β
easier debugging
If the endpoint changes, you update one filter. Not 20 selectors.
π© Telegram alerts in 10 seconds
Telegram sending is just a POST request to:
https://api.telegram.org/bot/sendMessage
Payload:
chat_id
text
Add a timeout so your monitor loop never hangs.
Result: when the best price crosses your threshold, you get a nice message instantly π
If you want to evolve this tool, here are easy upgrades:
π§½ deduplicate notifications so you do not spam yourself
π§· move threshold into .env or CLI args
π§ͺ add a --once mode to run a single check
π store history to a simple CSV for analysis
β Wrap up
If you are scraping a dynamic website and the data comes from JSON calls, intercepting the network layer is often the most robust solution.
This project is a tiny example of that approach:
Playwright for browser and network events
JSON parsing for structured data
Telegram for instant notifications
Repo again: https://github.com/AmaLS367/bybit-p2p-price-monitor
If you have ideas for improvements or want to contribute, PRs are welcome πͺπ₯
Top comments (0)