USDT to IRR price converter
Project description
USD to IRR Price Scraper
A lightweight, robust Python module to fetch the live USD to Iranian Rial (IRR) exchange rate from TGJU.
Quick Navigation
📋 Overview
This script scrapes the current dollar price from TGJU, one of Iran's most popular financial websites. Since financial websites often change their HTML structure, the scraper uses multiple fallback methods to remain reliable.
Features
✅ Resilient to website layout changes
✅ Multiple parsing strategies
✅ Returns clean integer price
✅ Lightweight and fast
✅ Supports English and Persian projects
✅ Easy integration with Telegram bots, dashboards, APIs, and automation tools
🛠️ How It Works
- Sends a GET request to:
https://www.tgju.org/profile/price_dollar_rl
-
Parses the HTML using BeautifulSoup
-
Attempts multiple extraction methods:
- data-price attribute
- CSS class matching
- Regex fallback
-
Cleans the result
-
Returns an integer price or None
📦 Installation
Requirements
pip install requests beautifulsoup4
Or install directly from:
pip install -r requirements.txt
requirements.txt
requests
beautifulsoup4
🚀 Usage
Python Source
from dollar_price import get_dollar_price
price = get_dollar_price()
if price:
print(f"Current Dollar Price: {price:,} Rials")
else:
print("Failed to fetch price")
Run Directly
python main.py
📁 Project Structure
dollar-price-scraper/
│
├── main.py
├── README.md
├── requirements.txt
└── LICENSE
🌍 Persian / فارسی
این پروژه قیمت لحظهای دلار را از وبسایت TGJU دریافت میکند.
ویژگیها:
- سبک و سریع
- مناسب برای رباتهای تلگرام
- دارای چندین روش جایگزین برای جلوگیری از خرابی اسکریپر
- مناسب برای پروژههای فارسی و انگلیسی
🌐 Use Cases
Telegram Bots
نمایش قیمت لحظهای دلار
Discord / WhatsApp Bots
هشدار تغییر قیمت ارز
Web Dashboards
Flask, FastAPI, Django
Trading Tools
سیستمهای آربیتراژ و تحلیل بازار
Finance Apps
اپلیکیشنهای مدیریت مالی
Data Collection
ذخیرهسازی قیمتهای تاریخی
🔧 Customization
Change Source
url = "https://www.tgju.org/profile/price_dollar_rl"
Add Cache
from functools import lru_cache
@lru_cache(maxsize=1)
def get_dollar_price_cached():
return get_dollar_price()
Logging & Alerts
Add Telegram, Email, Discord or SMS notifications inside exception handlers.
⚠️ Important Notes
- Respect TGJU terms of service.
- Add rate limits for frequent requests.
- Website structure may change over time.
- Intended for educational and personal use.
🤝 Contributing
Contributions are welcome.
Possible improvements:
- Additional fallback selectors
- Gold price support
- Euro support
- Async version
- Unit tests
- API wrapper
📬 Contact
GitHub
@EscCeo
Telegram
@xzaliu
X (Twitter)
@xzaliu
👨💻 Author
Created and maintained by Ali (@EscCeo)
Telegram: @xzaliu
X: @xzaliu
GitHub: @EscCeo
📄 License
MIT License
Free for personal and commercial use.
❤️ Made for the Iranian Developer Community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usdt_price_in_iran_toman_module-1.0.0.tar.gz.
File metadata
- Download URL: usdt_price_in_iran_toman_module-1.0.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a09d8330a4b1b2ed03153b121f0fae78465aaa4588f7e06d2847c9138a70e77
|
|
| MD5 |
b99e968342899da349610128547102f1
|
|
| BLAKE2b-256 |
b8ac44c0a468fd667aff89cb47427d59d755d442f951d35597322a21392d5539
|
File details
Details for the file usdt_price_in_iran_toman_module-1.0.0-py3-none-any.whl.
File metadata
- Download URL: usdt_price_in_iran_toman_module-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0095ad26e45cdbb27162df58dcd5bef6f6900d0187ffb500ccc7342ae79b0579
|
|
| MD5 |
c25adb1edcec68c813bdfc28c02ef478
|
|
| BLAKE2b-256 |
d4f18df1e571bd6f52e48ae6b825affec061f366b4be7ac141d1225d8f7e35f4
|