Skip to content
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

Instant error when running script #5

Open
PascalvanDongen opened this issue Jan 1, 2018 · 5 comments
Open

Instant error when running script #5

PascalvanDongen opened this issue Jan 1, 2018 · 5 comments

Comments

@PascalvanDongen
Copy link

When I run the script I get this error instantly: Traceback (most recent call last): File "twitterbot1.py", line 67, in <module> run() File "twitterbot1.py", line 62, in run search(api.search(q=key)) File "twitterbot1.py", line 37, in search if is_user_bot_hunter(str(i.author.name), str(i.author.screen_name)) == False: UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001f384' in position 0: ordinal not in range(128)

@EddRJ
Copy link

EddRJ commented Jan 4, 2018

Same issue here. The bot will run but then produce that error message after a few cycles, or it just produces that message instantly.

@robbiebarrat
Copy link
Owner

Alright so I rolled back to a previous commit where it doesn't throw that error; before i tried to update the bot detection measures...

It should be working now; but i remember @PascalvanDongen was having troubles with it retweeting some vegas giveaways account that it shouldn't be retweeting; give me 2 or 3 days and that'll be fixed, too.

@EddRJ
Copy link

EddRJ commented Jan 4, 2018

Working like a charm. Thank you.

@PascalvanDongen
Copy link
Author

Now i am getting this error: Traceback (most recent call last): File "twitterbot.py", line 67, in <module> run() File "twitterbot.py", line 62, in run search(api.search(q=key)) File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 245, in _call return method.execute() File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 229, in execute raise TweepError(error_msg, resp, api_code=api_error_code) tweepy.error.TweepError: [{u'message': u'Invalid or expired token.', u'code': 89}]

@Alkesst
Copy link
Contributor

Alkesst commented Jan 14, 2018

This error usually appears when using python 2.x due to the string encoding. Python 2.x uses ascii strings by default. It is required to use .encode('utf8')/.decode('utf8') in the right strings to avoid getting the error. Other way to avoid the error is by adding u"just a string" to all the strings.
(I regret for my bad english, I hope it helps)

P.S. Tweepy uses by default the unicode strings.

Alkesst added a commit to Alkesst/twitter-contest-enterer that referenced this issue Jan 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants