mahrtayyab / tweety

Twitter Scraper
494 stars 67 forks source link

Login Issue Persist After Update #221

Closed seleron closed 23 hours ago

seleron commented 1 day ago

The updated code doesn't work properly for me.

When tried without a session file or cookies but with un and password getting this error:

2024-11-22 23:54:10 DEBUG:receive_response_headers.started request=<Request [b'GET']> stream_id=3 2024-11-22 23:54:10 DEBUG:receive_response_headers.failed exception=RuntimeError('<asyncio.locks.Event object at 0xXXXXXXXX [unset]> is bound to a different event loop') 2024-11-22 23:54:10 DEBUG:response_closed.started stream_id=3 2024-11-22 23:54:10 DEBUG:response_closed.complete 2024-11-22 23:54:10 ERROR:Authentication failed: invalid response 2024-11-22 23:54:10 ERROR:Authentication failed: invalid response Traceback (most recent call last): File "/.py", line 39, in authenticate self.perform_authentication(username, password, extra) File "/.py", line 63, in perform_authentication raise auth_error File "/.py", line 55, in perform_authentication self.twitter_app.start(username, password, extra=extra) File "/site-packages/tweety/init.py", line 21, in wrapper return loop.run_until_complete(coro) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 56, in start return await self.sign_in(username, password, extra=_extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 103, in sign_in return await self._login() ^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 164, in _login response = await self.request.login(self._login_url, _payload=_login_payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/http.py", line 342, in login response = await self.get_response(True, **request_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/http.py", line 176, in get_response await self._init_local_api() File "/site-packages/tweety/http.py", line 167, in _init_local_api self._transaction = TransactionGenerator(home_page_html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/transaction.py", line 105, in init self.home_page_html = self.validate_response(home_page_html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/transaction.py", line 129, in validate_response raise Exception("invalid response") Exception: invalid response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/.py", line 107, in main trend_fetcher.authenticate(username=username, password=password) File "/.py", line 42, in authenticate self.perform_authentication(username, password, extra) File "/.py", line 63, in perform_authentication raise auth_error File "/.py", line 55, in perform_authentication self.twitter_app.start(username, password, extra=extra) File "/site-packages/tweety/init.py", line 21, in wrapper return loop.run_until_complete(coro) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 56, in start return await self.sign_in(username, password, extra=_extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 103, in sign_in return await self._login() ^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 164, in _login response = await self.request.login(self._login_url, _payload=_login_payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/http.py", line 342, in login response = await self.get_response(True, **request_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/http.py", line 176, in get_response await self._init_local_api() File "/site-packages/tweety/http.py", line 167, in _init_local_api self._transaction = TransactionGenerator(home_page_html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/transaction.py", line 105, in init self.home_page_html = self.validate_response(home_page_html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/transaction.py", line 129, in validate_response raise Exception("invalid response") Exception: invalid response

When tried with session file and cookie, getting this error:

2024-11-23 00:02:47 DEBUG:response_closed.started stream_id=17 2024-11-23 00:02:47 DEBUG:response_closed.complete 2024-11-23 00:02:47 ERROR:Authentication failed: 'Request' object has no attribute 'set_cookies' 2024-11-23 00:02:47 ERROR:Authentication failed: 'Request' object has no attribute 'set_cookies' Traceback (most recent call last): File "/.py", line 34, in authenticate self.twitter_app.connect() File "/site-packages/tweety/init.py", line 21, in wrapper return loop.run_until_complete(coro) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 22, in connect await self.request.verify_cookies() File "/site-packages/tweety/http.py", line 317, in verify_cookies raise InvalidCredentials(None, None, None) tweety.exceptions.InvalidCredentials: The Cookies are Invalid

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/.py", line 107, in main trend_fetcher.authenticate(username=username, password=password) File "/.py", line 42, in authenticate self.perform_authentication(username, password, extra) File "/.py", line 63, in perform_authentication raise auth_error File "/.py", line 55, in perform_authentication self.twitter_app.start(username, password, extra=extra) File "/site-packages/tweety/init.py", line 21, in wrapper return loop.run_until_complete(coro) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 56, in start return await self.sign_in(username, password, extra=_extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/site-packages/tweety/auth.py", line 89, in sign_in self.request.set_cookies("", False) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Request' object has no attribute 'set_cookies'

ContentPixelLLC commented 1 day ago

Getting this and 'NoneType' object has no attribute 'ct0'

zaksiddiqengineer commented 1 day ago

Getting this and 'NoneType' object has no attribute 'ct0'

How are you logging in? Exacrlt

mahrtayyab commented 1 day ago

https://github.com/mahrtayyab/tweety/commit/d64e98b6d998fd7a8317ea56433aba051547ae60

mahrtayyab commented 23 hours ago

run pip install lxml