Python Forum

Full Version: Syntax error for HTTP request GET
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I try to run my script I get a syntax error. Can anyone please tell me what's wrong?

Error:
[email protected]:~/Desktop $ python TONotificationScript.py File "TONotificationScript.py", line 11 with requests.get('https://tradeogre.com/api/v1/account/balances', auth=HTTPBasicAuth('***', '***') as response: ^ SyntaxError: invalid syntax
(the API keys are not valid)

The whole script is as follows:

import requests
import time
from playsound import playsound

oldData = None

while True:
    with requests.get('https://tradeogre.com/api/v1/account/balances', auth=HTTPBasicAuth('***', '***') as response:
        newData = response.read()
    if oldData is not None and newData != oldData:
        print('Change detected on TO')
        playsound('./Desktop/DEFCON level change.mp3')
        r = requests.post("https://api.pushover.net/1/messages.json", data = {
            "token": "***",
            "user": "***",
            "message": "Change detected on TO"
        },
        )
        print(r.text)
    oldData = newData    
    time.sleep(300)
Count parentheses) line 8.