Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax error for HTTP request GET
#1
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)
Reply
#2
Count parentheses) line 8.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  HTTP 404 error with Session Pool Clives 0 301 Jun-17-2021, 06:45 PM
Last Post: Clives
  error HTTP Error 403: Forbidden local_bit 1 1,245 Nov-14-2020, 11:34 AM
Last Post: ndc85430
  How to send unicode string encoded in utf-8 in http request in Python MaverinCode 1 17,669 Nov-08-2020, 06:45 AM
Last Post: JaiM
  urllib.error.HTTPError: HTTP Error 404: Not Found ckkkkk 4 4,662 Mar-03-2020, 11:30 AM
Last Post: snippsat
  python beginner HTTP Error 500 leofcastro 0 832 Jan-24-2020, 04:37 PM
Last Post: leofcastro
  Receiving Werkzeug. exception. Bad Request error when using GET with an endpoint robogeek 0 1,398 Jul-02-2019, 01:04 PM
Last Post: robogeek
  HTTP error 404 Karin 4 2,859 May-31-2019, 02:23 PM
Last Post: snippsat
  How to check HTTP error 500 and bypass SriMekala 3 2,443 May-04-2019, 02:07 PM
Last Post: snippsat
  HTTP Header request, how to improve efficiency andreamoro 5 3,304 May-01-2017, 03:49 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020