-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
self.driver.find_elements returns with [] can't find the text #3
Comments
Are you using GetMessager() or BotStart()? And it doesn't return any kind of error? |
I use it without changing. Botstart(). It doesn't return anything as text is empty that cause infinite loop. I also used different username, and got another error that closes the pages when message section is clicked. GetMessager() for my understanding is not applied anywhere |
Are you passing the parameters in the correct order? First comes the username and then the APIKEY. python InstagramBot.py <user> <apikey> I've just tested the bot here, and it's still working normally. if __name__ == "__main__":
if len(sys.argv) < 3:
raise Exception("USER and API_KEY is mandatory and must be passed as an argument.")
USER = sys.argv[1]
API_KEY = sys.argv[2]
print("Instagram User: ", USER)
print("API_KEY: ", API_KEY)
BotGPT = ChatBot(API_KEY)
InstBOT = InstagramBotGPT(user=USER, chatbot=BotGPT)
InstBOT.BotStart() |
No, unfortunately, I already used it in this way. I have used it on three PCs (mac and windows), it didn't work out. Which google chrome version you used? |
I use version 106.0.5249.103. Does your browser simply close or is the bot unable to respond? Maybe instagram is different in your region. Can you send a screenshot of the steps or where the script break? |
I use 109 version. The bot doesn’t find any text. I’ve printed it out but the result is “[]”
And one more question; is there a way to create a chatbot that can communicate with my insta friends if they send message. I guess we need to use InstaAPI for that
…Sent from my iPhone
On 22 Feb 2023, at 19:18, José Henrique Siqueira ***@***.***> wrote:
I use version 106.0.5249.103. Does your browser simply close or is the bot unable to respond? Maybe instagram is different in your region. Can you send a screenshot of the steps or where the script break?
—
Reply to this email directly, view it on GitHub<#3 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIMFH4K2FGHYJ6TKZKYNCY3WYZRBJANCNFSM6AAAAAAVDCGVRE>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
can you open the script and try to use the getmessanger method? it is exactly for debug. It will check if it is capturing user or author messages. if __name__ == "__main__":
InstBOT = InstagramBotGPT(user='type_any_user_here', chatbot=None)
author_msg = InstBOT.GetMessager('author')
user_msg = InstBOT.GetMessager('user')
print("\nAUTHOR_MESSAGES:", author_msg)
print("\nUSER_MESSAGES:", user_msg) That way you don't need to pass the parameters. Try using it like this and check if any of the variable values are printed: python InstagramBot.py By the way, check that the user is correct with the Instagram one. User example: About your second question: |
Yes, I have tried it and it gives empty text and It did not open messages at all. And this is the output after the page is closed automatically.
I guess the problem is related to BY.CLASS_NAME. I will also search this out to capture the texts. Thanks for the debugging clue. For the second question, I was meaning that a more autonomous way to do that without entering the target name. E.g. Just the author username is entered and the bot is alive. So it can answer whoever asks a question. |
Can you provide me with the full version of chrome you are trying? So I add it to the repository that is malfunctioning with that specific version. About your question about the bot, yes it is possible. With a little web scraping you can do it. I would try as follows. |
Version 110.0.5481.100, I am not sure if it is related to a google chrome version though. Thanks anyway for your comments. |
I think it's some version of Instagram. I could fix it for you, I'll try to find an alternative class to get the text. |
I've updated the repository and added selinium functionality that waits for the element to be loaded before proceeding. Perhaps the problem was that your script ran before the class itself loaded. Try using prints() again in GetMessager() |
I am receiving this now. It exceeds the wait time. I think the problem is the same. For some reason, BY.class_name does not get the text from the inspected class. |
Problem solved. I accidentally changed the user by refoctoring Types = {"author":"_acqv", 'user':'_acqu'} with an instagram user name |
Now both methods are working and returning messages? |
Yes, I can receive both messages. Also, another problem was stemming from when author and username is same.
sometime it doesn’t recognise some usernames such as my fake account e.g “user1234” as user. But when I enter my fake account as author it works
Sent from Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: José Henrique Siqueira ***@***.***>
Sent: Friday, February 24, 2023 1:09:50 AM
To: JoseHenriqueSiqueira/Whatsapp_Instagram_Messanger_ChatGPT_OpenAI ***@***.***>
Cc: Vural Erdogan ***@***.***>; State change ***@***.***>
Subject: Re: [JoseHenriqueSiqueira/Whatsapp_Instagram_Messanger_ChatGPT_OpenAI] self.driver.find_elements returns with [] can't find the text (Issue #3)
Now both methods are working and returning messages?
—
Reply to this email directly, view it on GitHub<#3 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIMFH4KGOWN4BNLF5YUWKZLWZAC55ANCNFSM6AAAAAAVDCGVRE>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
Right. This issue has been resolved. The other problem I will study a little what could be the cause and simulate some scenarios |
instagrambot.py messages_element = self.driver.find_elements(By.CLASS_NAME, username) does not return as expected. Therefore, the codes are stuck in while loop as there is no message
The text was updated successfully, but these errors were encountered: