Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Task index - list index out of range #5

Closed
4yR1l1k opened this issue Jul 7, 2023 · 2 comments
Closed

Task index - list index out of range #5

4yR1l1k opened this issue Jul 7, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@4yR1l1k
Copy link

4yR1l1k commented Jul 7, 2023

Python version: 3.10

Code:
from tweeterpy import TweeterPy
from tweeterpy import config

def main():
config.TIMEOUT = 5
config.PROXY = {'http': 'xx.xxx.xx.xx', 'https': 'xx.xxx.xx.xx'}
twitter = TweeterPy()
print(twitter.get_user_id('elonmusk'))
print(twitter.get_user_info('elonmusk'))
# print(twitter.get_user_data('elonmusk'))
# print(twitter.get_user_tweets('elonmusk', total=200))
# print(twitter.get_user_media('elonmusk', total=100))

if name == "main":
main()

Error:
Traceback (most recent call last):
File "/home/machine/Desktop/twscrape/id.py", line 17, in
main()
File "/home/machine/Desktop/twscrape/id.py", line 9, in main
print(twitter.get_user_id('elonmusk'))
File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 110, in wrapper
self.login()
File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 189, in login
TaskHandler().login(username, password)
File "/usr/local/lib/python3.10/site-packages/tweeterpy/#_util.py", line 91, in login
task_id = [task_id for task_id in task_flow_mapper.keys() if task_id in tasks][0]
IndexError: list index out of range

Question:

I've just found a proxy and trying your example code above. The twitter username and password are applied correctly. What am I doing wrong and getting this error?

@iSarabjitDhiman
Copy link
Owner

iSarabjitDhiman commented Jul 7, 2023

Python version: 3.10

Code:
from tweeterpy import TweeterPy
from tweeterpy import config

def main():
config.TIMEOUT = 5
config.PROXY = {'http': 'xx.xxx.xx.xx', 'https': 'xx.xxx.xx.xx'}
twitter = TweeterPy()
print(twitter.get_user_id('elonmusk'))
print(twitter.get_user_info('elonmusk'))
# print(twitter.get_user_data('elonmusk'))
# print(twitter.get_user_tweets('elonmusk', total=200))
# print(twitter.get_user_media('elonmusk', total=100))

if name == "main":
main()

Error:
Traceback (most recent call last):
File "/home/machine/Desktop/twscrape/id.py", line 17, in
main()
File "/home/machine/Desktop/twscrape/id.py", line 9, in main
print(twitter.get_user_id('elonmusk'))
File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 110, in wrapper
self.login()
File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 189, in login
TaskHandler().login(username, password)
File "/usr/local/lib/python3.10/site-packages/tweeterpy/#_util.py", line 91, in login
task_id = [task_id for task_id in task_flow_mapper.keys() if task_id in tasks][0]
IndexError: list index out of range

Question:

I've just found a proxy and trying your example code above. The twitter username and password are applied correctly. What am I doing wrong and getting this error?

Have you tried it without the proxy ? If it's working without the proxy, then you have to use premium proxies i.e. residential proxies.
Also check if you have two factor authentication enabled, if yes, then log into your regular web browser, head over to developer tools(inspect element) then from the cookies section, copy auth-token.
And use auth-token to login into TweeterPy with generate_session(auth_token="auth-token-you-copied-from-browser") and then you are good to go.

In your case its going to be something like this :

from tweeterpy import TweeterPy
from tweeterpy import config

def main():
    config.TIMEOUT = 5
    config.PROXY = {"http":"proxyhere","https":"proxyhere"}
    twitter = TweeterPy()
    twitter.generate_session(auth_token="token-you-copied")
    #twitter.save_session() #use this if u want to reuse the same session in future. Next time u can use twitter.load_session() instead of using .login() or .generate_session()
    print(twitter.get_user_data("elonmusk"))

if __name__ == "__main__":
    main()
   

Check documentation for more information.

@iSarabjitDhiman iSarabjitDhiman added question Further information is requested bug Something isn't working and removed question Further information is requested labels Jul 11, 2023
@iSarabjitDhiman
Copy link
Owner

Python version: 3.10

Code: from tweeterpy import TweeterPy from tweeterpy import config

def main(): config.TIMEOUT = 5 config.PROXY = {'http': 'xx.xxx.xx.xx', 'https': 'xx.xxx.xx.xx'} twitter = TweeterPy() print(twitter.get_user_id('elonmusk')) print(twitter.get_user_info('elonmusk')) # print(twitter.get_user_data('elonmusk')) # print(twitter.get_user_tweets('elonmusk', total=200)) # print(twitter.get_user_media('elonmusk', total=100))

if name == "main": main()

Error: Traceback (most recent call last): File "/home/machine/Desktop/twscrape/id.py", line 17, in main() File "/home/machine/Desktop/twscrape/id.py", line 9, in main print(twitter.get_user_id('elonmusk')) File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 110, in wrapper self.login() File "/usr/local/lib/python3.10/site-packages/tweeterpy/tweeterpy.py", line 189, in login TaskHandler().login(username, password) File "/usr/local/lib/python3.10/site-packages/tweeterpy/#_util.py", line 91, in login task_id = [task_id for task_id in task_flow_mapper.keys() if task_id in tasks][0] IndexError: list index out of range

Question:

I've just found a proxy and trying your example code above. The twitter username and password are applied correctly. What am I doing wrong and getting this error?

Hey, I guess it was some issue with the login method. I just fixed it. Hopefully, it should be working fine now. Try it !!

@iSarabjitDhiman iSarabjitDhiman changed the title Task index - list iindex out of range Task index - list index out of range Jul 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants