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

get_trends not working with 'news' and 'sports' categories #287

Open
ericjkge opened this issue Jan 12, 2025 · 0 comments
Open

get_trends not working with 'news' and 'sports' categories #287

ericjkge opened this issue Jan 12, 2025 · 0 comments

Comments

@ericjkge
Copy link

I've been trying to use twikit to get trends from X, but the get_trends function doesn't work when I use 'news' or 'sports' as my category ('trending,' 'for-you,' and 'entertainment' work fine). Below is the error code from trying to use news:

Traceback (most recent call last):
File "/Users/ericge/Code/Coscribe-AI/x_scraper.py", line 23, in
result = asyncio.run(scrape_x(username, email, password, topic))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/ericge/Code/Coscribe-AI/x_scraper.py", line 10, in scrape_x
results = await cl.get_trends(category='news', count=10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/twikit/client/client.py", line 2589, in get_trends
trend_info = item['item']['content']['trend']
~~~~~~~^^^^^^^^^
KeyError: 'trend'

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

1 participant