Skip to content

Commit

Permalink
Fix vesprice cron
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Jun 26, 2024
1 parent 6a8c10d commit 6704066
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions vesprice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
rdata = redis.StrictRedis(host=os.getenv(
'REDIS_HOST', 'localhost'), port=6379)

dolartoday_price = 'https://s3.amazonaws.com/dolartoday/data.json'
dolartoday_price = "https://dolartoday.com/wp-admin/admin-ajax.php"

# Form data to be sent with the request
data = {
"action": "dt_currency_calculator_handler",
"amount": 1
}


def dolartoday_bolivar():
response = json.loads(requests.get(url=dolartoday_price).text)
if "USD" not in response:
response = json.loads(requests.post(url=dolartoday_price, data=data).text)
if "Dólar Bitcoin" not in response:
print("Invalid response " + str(response))
return
bolivarprice = response['USD']['localbitcoin_ref']
# Get the "Dólar Bitcoin" value
bitcoin_dollar_value = response["Dólar Bitcoin"]

# Extract the numerical value from the string
bolivarprice = float(bitcoin_dollar_value.split()[1])
if bolivarprice is None:
print("Couldn't find localbitcoin_ref price")
return
Expand Down

0 comments on commit 6704066

Please sign in to comment.