twitterresearch
twitterresearch copied to clipboard
examples.print_user_archive()
I have the following error:
In [5]: examples.print_user_archive()
TypeError Traceback (most recent call last)
/home/ubuntu/twitterresearch/examples.pyc in print_user_archive() 111 """ 112 archive_generator = rest.fetch_user_archive("lessig") --> 113 for page in archive_generator: 114 for tweet in page: 115 print_tweet(tweet)
/home/ubuntu/twitterresearch/rest.pyc in fetch_user_archive(user, **kwargs) 261 # If we have a valid max_id, use that; else do a simple normal request 262 result, tweets = fetch_user_tweets( --> 263 user, max_id=max_id, **kwargs) if max_id else fetch_user_tweets(user) 264 # Set the status variable - if it's not 200, that's an error and the loop exits 265 status = result.status_code
/home/ubuntu/twitterresearch/rest.pyc in fetch_user_tweets(user, **kwargs) 237 elif isinstance(user, str): 238 kwargs['screen_name'] = user --> 239 result = throttled_call(USER_TIMELINE_URL, params=kwargs) 240 # Decode JSON 241 return (result, json.loads(result.text))
/home/ubuntu/twitterresearch/rest.pyc in wrapper(*args, **kwargs) 141 patched_data = lengthen_text(response_json) 142 # Monkey patching since .text and .content are read-only --> 143 response._content = bytes(json.dumps(patched_data), encoding='utf-8') 144 return response 145 return wrapper
TypeError: str() takes at most 1 argument (2 given)
Hi, the example works for me. That error basically says that at some point, we try to print/display one thing but get two. I suspect you might be getting an error which can't be displayed. Could you try the raw call:
result, tweets = fetch_user_tweets("lessig")
And post the contents of result and tweets?
I recently had the same issue but it disappeared after downloading a fresh clone. Do you have an up-to-date version of the package on your system, @JoseCR99 ?
Thanks for the hint, @Millesimus. Always worth trying out.