Skip to content

Commit

Permalink
Merge pull request #92 from MamdMehrabi/main
Browse files Browse the repository at this point in the history
add trx_price
  • Loading branch information
AmirAli Irvani authored Jul 2, 2024
2 parents 5f53a96 + d656087 commit b26113a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def custom_404_handler(request: Request, __):
"app.router.api.datetime.router",
"app.router.api.dictionary.router",
"app.router.api.fake.router",
"app.router.api.trx.router",
"app.router.api._github.router",
"app.router.api.location.router",
"app.router.api.news.router",
Expand Down
28 changes: 28 additions & 0 deletions app/router/api/trx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
In this api, by using request and crypto site,
we get the current price of Tron currency...
"""

from fastapi import APIRouter, Response, status

from requests import post
from bs4 import BeautifulSoup

router = APIRouter(prefix='/api', tags=["Crypto"])

def TRX():
a = post("https://arzdigital.com/coins/tron/")
soup = BeautifulSoup(a.content , "html.parser")
find = soup.find("div", {"class":"arz-coin-page-data__coin-toman-price"}).text.strip()
return find

@router.get('/tron', status_code=status.HTTP_200_OK)
@router.post('/tron', status_code=status.HTTP_200_OK)
async def tron():
price = TRX()
return {
"success": True,
"data": {
"price_tron": price
}
}

0 comments on commit b26113a

Please sign in to comment.