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:
pi@raspberrypi:~/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
Question Responding correctly to HTTP request Calab 2 2,686 Apr-14-2023, 04:11 PM
Last Post: Calab
  HTTP 404 error with Session Pool Clives 0 2,126 Jun-17-2021, 06:45 PM
Last Post: Clives
  error HTTP Error 403: Forbidden local_bit 1 4,713 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 38,727 Nov-08-2020, 06:45 AM
Last Post: JaiM
  urllib.error.HTTPError: HTTP Error 404: Not Found ckkkkk 4 11,758 Mar-03-2020, 11:30 AM
Last Post: snippsat
  python beginner HTTP Error 500 leofcastro 0 3,400 Jan-24-2020, 04:37 PM
Last Post: leofcastro
  Receiving Werkzeug. exception. Bad Request error when using GET with an endpoint robogeek 0 3,696 Jul-02-2019, 01:04 PM
Last Post: robogeek
  HTTP error 404 Karin 4 6,441 May-31-2019, 02:23 PM
Last Post: snippsat
  How to check HTTP error 500 and bypass SriMekala 3 15,594 May-04-2019, 02:07 PM
Last Post: snippsat
  HTTP Header request, how to improve efficiency andreamoro 5 7,036 May-01-2017, 03:49 PM
Last Post: micseydel

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.