-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raise JSONDecodeError("Expecting value", s, err.value) from None #113
Comments
try removing the "d = d.encode('utf-8') " |
If I wont encode and if the tweet contains an emoji it Throws JSONDecodeError error. |
oh, is that how you have the code exactly in the file? |
Yes, Well Its so weird but it works for some time and it stops all of a sudden. |
Yeah it might of ip banned you temporary. def translate(trans):
try:
trans = raw_input("Enter word/words here: ")
translations = translator.translate([trans], dest='en')
for translation in translations:
print(translation.origin, ' English -> ', translation.text)
except:
try:
trans_encode = trans.encode("ascii", "ignore")
translations = translator.translate([trans_encode], dest='en')
for translation in translations:
print(translation.origin, ' English -> ', translation.text)
except:
pass
trans = ''
threading.Thread(translate(trans)).start() |
This is what I had to do to bypass their API call restriction... I use a VPN, specifically Nord-Vpn, so to do it the way I did you would need to be able to connect/disconnect from/to a VPN through the terminal... def translate_text(text, dest_language="en"):
# Used to translate using the googletrans library
import json
translator = googletrans.Translator()
try:
translation = translator.translate(text=text, dest=dest_language)
except json.decoder.JSONDecodeError:
# api call restriction
process = subprocess.Popen(["nordvpn", "d"], stdout=subprocess.PIPE)
process.wait()
process = subprocess.Popen(["nordvpn", "c", "canada"], stdout=subprocess.PIPE)
process.wait()
return Process_Data.translate_text(text=text, dest_language=dest_language)
return translation |
I did import "subprocess" but how would "Process_Data" work? as is I tried pip install Process_Data but didn't think it worked |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am getting the below error when I try to translate a Portuguese tweet to English.
"raise JSONDecodeError("Expecting value", s, err.value) from None"
I have tried to encode the string, tried to limit the string to only 3000 characters nothing works.
Please advise how can i fix this?
The issues which were raised by others and the solutions provided are not working for me
Below is my code.
Error
The text was updated successfully, but these errors were encountered: