Skip to main content

USDT to IRR price converter

Project description

GitHub Telegram X Requirements Python

USD to IRR Price Scraper

Python License Status English Docs

Persian Docs

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

  1. Sends a GET request to:

https://www.tgju.org/profile/price_dollar_rl

  1. Parses the HTML using BeautifulSoup

  2. Attempts multiple extraction methods:

  • data-price attribute
  • CSS class matching
  • Regex fallback
  1. Cleans the result

  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usdt_price_in_iran_toman_module-1.0.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file usdt_price_in_iran_toman_module-1.0.0.tar.gz.

File metadata

File hashes

Hashes for usdt_price_in_iran_toman_module-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2a09d8330a4b1b2ed03153b121f0fae78465aaa4588f7e06d2847c9138a70e77
MD5 b99e968342899da349610128547102f1
BLAKE2b-256 b8ac44c0a468fd667aff89cb47427d59d755d442f951d35597322a21392d5539

See more details on using hashes here.

File details

Details for the file usdt_price_in_iran_toman_module-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for usdt_price_in_iran_toman_module-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0095ad26e45cdbb27162df58dcd5bef6f6900d0187ffb500ccc7342ae79b0579
MD5 c25adb1edcec68c813bdfc28c02ef478
BLAKE2b-256 d4f18df1e571bd6f52e48ae6b825affec061f366b4be7ac141d1225d8f7e35f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page