Closed chongqiangchen closed 10 months ago
code
from tweeterpy import TweeterPy
twitter = TweeterPy()
print(twitter.get_user_id('elonmusk'
error:
Traceback (most recent call last):
File "D:\program\python\lib\site-packages\tweeterpy\api_util.py", line 68, 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-12 02:18:47,707 [DEBUG] [Line No. 82] tweeterpy.api_util : _get_main_file_url :: Main File Url => https://abs.twimg.com/responsive-web/client-web/main.0892a5da.js
2023-11-12 02:18:47,708 [DEBUG] [Line No. 20] tweeterpy.request_util : make_request :: {'url': 'https://abs.twimg.com/responsive-web/client-web/main.0892a5da.js', 'session': <requests.sessions.Session object at 0x0000019B3395AFB0>, 'method': 'GET', 'max_retries': 3, 'timeout': 5, 'skip_error_checking': False, 'kwargs': {}}
2023-11-12 02:18:47,709 [DEBUG] [Line No. 1053] urllib3.connectionpool : _new_conn :: Starting new HTTPS connection (1): abs.twimg.com:443
2023-11-12 02:18:47,961 [DEBUG] [Line No. 547] urllib3.connectionpool : _make_request :: https://abs.twimg.com:443 "GET /responsive-web/client-web/main.0892a5da.js HTTP/1.1" 200 523643
2023-11-12 02:18:48,226 [DEBUG] [Line No. 437] charset_normalizer : from_bytes :: Encoding detection: utf_8 is most likely the one.
2023-11-12 02:18:48,431 [WARNING] [Line No. 48] tweeterpy.api_util : __init__ :: Object literal (dictionary) is not terminated Couldn't get the latest API data.
2023-11-12 02:18:48,431 [DEBUG] [Line No. 49] tweeterpy.api_util : __init__ :: Trying to restore API data from the backup file.
2023-11-12 02:18:48,432 [WARNING] [Line No. 168] tweeterpy.api_util : _load_api_data :: Couldn't find the API backup file.
2023-11-12 02:18:48,432 [WARNING] [Line No. 177] tweeterpy.api_util : _load_api_data :: Couldn't restore API data from the backup file.
Object literal (dictionary) is not terminated
2023-11-12 02:18:48,432 [ERROR] [Line No. 57] tweeterpy.api_util : __init__ :: API Couldn't be Updated.
Object literal (dictionary) is not terminated
Traceback (most recent call last):
File "D:\program\python\lib\site-packages\tweeterpy\api_util.py", line 50, in __init__
feature_switches, api_endpoints_data = self._load_api_data()
File "D:\program\python\lib\site-packages\tweeterpy\api_util.py", line 45, in __init__
api_endpoints_data = self._js_to_py_dict(api_files_data)
File "D:\program\python\lib\site-packages\tweeterpy\api_util.py", line 107, in _js_to_py_dict
dict_data = [demjson3.decode("{" + each_match)
File "D:\program\python\lib\site-packages\tweeterpy\api_util.py", line 107, in <listcomp>
dict_data = [demjson3.decode("{" + each_match)
File "D:\program\python\lib\site-packages\demjson3.py", line 6070, in decode
result = j.decode(
File "D:\program\python\lib\site-packages\demjson3.py", line 5257, in decode
raise errors[0]
demjson3.JSONDecodeError: Object literal (dictionary) is not terminated
Hey @chongqiangchen , thanks for bringing it to my attention. Twitter made some changes to the platform lately. Therefore the ApiUpdater is not working at the moment. I have disabled it for now, I will fix it later. I am kind of busy this week, so will not be able to fix it that soon. Thats why I have disabled the api updater for now, and the script should be working fine now. Just clone the most recent commit or you can update the library by using following command:
pip install tweeterpy -U
I just run quickstart.py, but I get error:
demjson3.JSONDecodeError: Object literal (dictionary) is not terminated