iSarabjitDhiman / TweeterPy

TweeterPy is a python library to extract data from Twitter. TweeterPy API lets you scrape data from a user's profile like username, userid, bio, followers/followings list, profile media, tweets, etc.
MIT License
138 stars 20 forks source link

Unexpected Keyword Argument when calling twitter.get_user_tweets() #11

Closed shoaibiqbalk closed 1 year ago

shoaibiqbalk commented 1 year ago

Get the unexpected keyword argument error when I use the following code.

from tweeterpy import TweeterPy
twitter = TweeterPy()
twitter.get_user_tweets(user_id, with_replies=True, end_cursor=None, total=2, from_date='19-07-2023', to_date='20-07-2023')

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-33-3ea1522e5413>](https://localhost:8080/#) in <cell line: 3>()
      1 # from_date = '19 July 2023'
      2 # to_date = '20 July 2023'
----> 3 tweets_by_user_id = twitter.get_user_tweets(user_id, with_replies=True, end_cursor=None, total=2, from_date='19-07-2023', to_date='20-07-2023')

[/usr/local/lib/python3.10/dist-packages/tweeterpy/tweeterpy.py](https://localhost:8080/#) in wrapper(self, *args, **kwargs)
    109             if not self.logged_in():
    110                 self.login()
--> 111             return original_function(self, *args, **kwargs)
    112         return wrapper
    113 

TypeError: TweeterPy.get_user_tweets() got an unexpected keyword argument 'from_date'
iSarabjitDhiman commented 1 year ago

Get the unexpected keyword argument error when I use the following code.

from tweeterpy import TweeterPy
twitter = TweeterPy()
twitter.get_user_tweets(user_id, with_replies=True, end_cursor=None, total=2, from_date='19-07-2023', to_date='20-07-2023')

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-33-3ea1522e5413>](https://localhost:8080/#) in <cell line: 3>()
      1 # from_date = '19 July 2023'
      2 # to_date = '20 July 2023'
----> 3 tweets_by_user_id = twitter.get_user_tweets(user_id, with_replies=True, end_cursor=None, total=2, from_date='19-07-2023', to_date='20-07-2023')

[/usr/local/lib/python3.10/dist-packages/tweeterpy/tweeterpy.py](https://localhost:8080/#) in wrapper(self, *args, **kwargs)
    109             if not self.logged_in():
    110                 self.login()
--> 111             return original_function(self, *args, **kwargs)
    112         return wrapper
    113 

TypeError: TweeterPy.get_user_tweets() got an unexpected keyword argument 'from_date'

Hey, I just noticed you are using the master branch. Make sure you clone the async-await branch first and install the requirements. from_date and to_date arguments only work with the async-await branch for now. I will merge it into the master branch soon. But for now you will have to git clone async-await branch.

Edit : Once you have tested it, let me know if it should be merged into the master branch. I am open to suggestions.

iSarabjitDhiman commented 1 year ago

Hey @shoaibiqbalk @nballen-tx Just navigate to this async-await branch . There you should see a green button saying "Code", click on the dropdown menu just beside it. Then download the zip. image

If are familiar with the linux file system and all, you can just extract the zip and run the code from the same directory. you may not even have to install the package, you can just import the required code into your project from the working directory.

Otherwise the easier option :

pip install setuptools
pip install -r requirements.txt
python setup.py sdist bdist_wheel

and then you should see a dist folder, you can install the package from there. just install the latest build/version ending with .whl extension. In my case its 0.0.9

pip install .\dist\tweeterpy-0.0.9-py3-none-any.whl

Now you are good to go, you can import the package into your project as you would normally.

from tweeterpy import TweeterPy

Let me know if you still need any help.

Edit : You can uninstall it anytime and go back to master(stable) branch anytime.

pip uninstall tweeterpy
pip install tweeterpy --upgrade

Feel free to close the issue if no further queries.