Reputation: 1
import http.client
conn = http.client.HTTPSConnection(“farasa-api.qcri.org”) payload = “{\”text\”: \”هذا مثال بسيط\”}”
headers = { ‘content-type’: “application/json”, ‘cache-control’: “no-cache”, }
conn.request(“POST”, “/msa/webapi/lemma”, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode(“utf-8”))
the result is showing as this
File "<ipython-input-61-b6148c5a04bb>", line 3
conn = http.client.HTTPSConnection(“farasa-api.qcri.org”) payload = “{\”text\”: \”هذا مثال بسيط\”}”
^
SyntaxError: invalid character in identifier
can anyone help? I need to import this api.
Upvotes: 0
Views: 66
Reputation: 1084
Payload have to be under your conn and your double quote are "different" than normal :
conn = http.client.HTTPSConnection("farasa-api.qcri.org")
payload = "{\"text\": \"هذا مثال بسيط\"}"
headers = { 'content-type': "application/json", 'cache-control': "no-cache", }
conn.request("POST", "/msa/webapi/lemma", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Upvotes: 2