Skip to content

Commit

Permalink
Prevent KeyError while searching tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
pothitos committed Apr 23, 2024
1 parent 1aec953 commit 90b4848
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions twikit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ def search_tweet(
tweet_info = tweet_info[0]
if 'tweet' in tweet_info:
tweet_info = tweet_info['tweet']
if 'core' not in tweet_info:
continue
if 'result' not in tweet_info['core']['user_results']:
continue
user_info = tweet_info['core']['user_results']['result']
Expand Down
2 changes: 2 additions & 0 deletions twikit/twikit_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ async def search_tweet(
tweet_info = tweet_info[0]
if 'tweet' in tweet_info:
tweet_info = tweet_info['tweet']
if 'core' not in tweet_info:
continue
if 'result' not in tweet_info['core']['user_results']:
continue
user_info = tweet_info['core']['user_results']['result']
Expand Down

0 comments on commit 90b4848

Please sign in to comment.