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
145 stars 20 forks source link

API Issues when attempting to use it? #43

Closed JewishLewish closed 11 months ago

JewishLewish commented 11 months ago

Python Code:

from tweeterpy import TweeterPy
from tweeterpy import config
from tweeterpy.util import find_nested_key

config.UPDATE_API=True

def main():
    config.TIMEOUT = 5
    twitter = TweeterPy()

if __name__ == "__main__":
    main()
2023-11-05 18:17:33,072 [ERROR] :: Couldn't get the API Url.
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "C:\Users\___\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 59, in _get_api_file_url
    api_file_name = re.search(api_file_regex, page_source).group(1)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
2023-11-05 18:17:33,073 [WARNING] :: 'NoneType' object has no attribute 'group' Couldn't get the latest API data.
2023-11-05 18:17:33,074 [WARNING] :: Couldn't find the API backup file.
2023-11-05 18:17:33,075 [WARNING] :: Couldn't restore API data from the backup file.
'NoneType' object has no attribute 'group'
2023-11-05 18:17:33,075 [ERROR] :: API Couldn't be Updated.
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "C:\Users\____\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 41, in __init__
    feature_switches, api_endpoints_data = self._load_api_data()
                                           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\___\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 34, in __init__
    api_file_url = self._get_api_file_url(page_source)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\____\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 59, in _get_api_file_url
    api_file_name = re.search(api_file_regex, page_source).group(1)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "c:\Users\____\Desktop\VS-Code\Otis\test.py", line 13, in <module>
    main()
  File "c:\Users\____\Desktop\VS-Code\Otis\test.py", line 9, in main
    twitter = TweeterPy()
              ^^^^^^^^^^^
  File "C:\Users\____\AppData\Roaming\Python\Python311\site-packages\tweeterpy\tweeterpy.py", line 31, in __init__
    ApiUpdater(update_api=config.UPDATE_API)
  File "C:\Users\___\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 41, in __init__
    feature_switches, api_endpoints_data = self._load_api_data()
                                           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\____\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 34, in __init__
    api_file_url = self._get_api_file_url(page_source)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\_____\AppData\Roaming\Python\Python311\site-packages\tweeterpy\api_util.py", line 59, in _get_api_file_url
    api_file_name = re.search(api_file_regex, page_source).group(1)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'

I tried using API for first time and it just crashed?

JewishLewish commented 11 months ago

Update I found solution, just uninstall the module and re-install it.

it does output this error for some reason

    api_file_name = re.search(api_file_regex, page_source).group(1)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
2023-11-05 18:21:21,741 [INFO] :: API Updated Successfully.
44196397
iSarabjitDhiman commented 11 months ago

Hey @JewishLewish Yes, I chose to keep that error, because this used to be the method I used to update the api, but recently it changed. I am not sure if it's gone for sure or it's temporary. I know it's annoying. So I guess I am gonna have to suppress the error.

Edit : suppressed the api update error for the time being. 5cfc5ee