shine-jayakumar / insta-likecom-bot

Automates likes and comments on an instagram account or tag
MIT License
140 stars 30 forks source link

[BUG] Headless mode not loading profile #67

Open ap0l0 opened 1 year ago

ap0l0 commented 1 year ago

Seems like headless mode is not loading profile. It does the entire sequence in every run:

=> Script started
[*] => Downloading webdriver for your version of Chrome
[*] => Loading Instagram
[*] => Running in headless mode
[*] => Delay: 2-15 secs
[*] => Max. comments to like: 2
[*] => Using profile: /Users/xx/Library/Application Support/Google/Chrome/Default
[*] => Launching Instagram
[*] => [launch_insta]: Attempt - 1
[*] => Checking if user is already logged in
[*] => [Attempt# 1] Validating login

[*] => Failed to validate login
[*] => [Attempt# 2] Validating login
[*] => Failed to validate login
[*] => [Attempt# 3] Validating login
[*] => Failed to validate login
[*] => User not logged in. Attempting to login
[*] => Could not locate 2 factor authentication screen
[*] => Could not locate 2 factor authentication screen
[*] => Validating login
[*] => [Attempt# 1] Validating login
[*] => Logged in successfully
shine-jayakumar commented 1 year ago

The first time you run it with a profile, you're required to enter your 2-factor auth code, even if the profile you're using has the credentials already saved. Once you enter your code, script will save the login for the next time (click on 'Save Login info'). The next time you run the script with profile, script can land directly on the user's page, skipping login and 2-factor auth screen.

It's working for me.

[*] => Script started
[*] => Downloading webdriver for your version of Chrome
[*] => Loading Instagram
[*] => Running in headless mode
[*] => Delay: 1-10 secs
[*] => Using profile: /home/user/.config/google-chrome/Profile 1
[*] => Launching Instagram
[*] => [launch_insta]: Attempt - 1
[*] => Checking if user is already logged in
[*] => [Attempt# 1] Validating login
[*] => Setting target to: ed_garlands
[*] => Opening target ed_garlands
[*] => [open_target]: Attempt - 1
[*] => Finding followers of ed_garlands
[*] => Restricting followers search to: 2
[*] => Opening followers list
[*] => Getting updated list of username divs
[*] => StaleElementReferenceException exception occured while capturing username links
[*] => Capturing div containing followers' list
[*] => Processing userdiv range: 0 - 22
[*] => Total username count: 2
ap0l0 commented 1 year ago

I think it happens when a new profile file is created, even if the Chrome profile is the same. It's a minor issue anyway, maybe is something local