I just want my file to stay open so I can run functions [closed]

  python

I don’t get it. My code works fine. I can run it through the command line or in the IDLE without a problem. I just want it to stay open in the Python shell so I can run my functions. When I run it normally, it just closes after running the initial class function. How do I do that? I’ve heard about the interactive mode -i but it won’t work, as shown below. I’ve looked at 10 or so different web pages and can’t find anything. I’m using python 3.

from selenium import webdriver
from time import sleep
chromedriver_path = 'D:/chromedriver.exe' # Change this to YOUR path

class instabot:
    def __init__(self, username, pw):
        self.username = username
        self.driver = webdriver.Chrome(executable_path=chromedriver_path)
        self.driver.get('https://www.instagram.com/accounts/login/?source=auth_switcher') 
        sleep(2) 

        uname = self.driver.find_element_by_name('username') 
        uname.send_keys(username) 
        pword = self.driver.find_element_by_name('password')
        pword.send_keys(pw)

        button_login = self.driver.find_element_by_css_selector('#loginForm > div > div:nth-child(3)')
        button_login.click()
        sleep(3)

        button_login = self.driver.find_element_by_css_selector(
            '#react-root > section > main > div > div > div > div > button')
        button_login.click()
        sleep(3)

        button_login = self.driver.find_element_by_css_selector(
            'body > div.RnEpo.Yx5HN > div > div > div > div.mt3GC > button.aOOlW.HoLwm')
        button_login.click()
        sleep(3) 

    def get_unfollowers(self):
        self.driver.get('https://www.instagram.com/'+self.username+'/')
        sleep(3)

username = "weedloveapuff"
password = "HhgffgpwUlL,843+&_g"
dropbot = instabot(username,password)

Source: Python Questions

LEAVE A COMMENT