<commit_before>from selenium import webdriver
import time

URL = "https://www.instagram.com/?hl=ja"
WAIT_TIME = 1800
WAIT_LOADING_TIME = 5

class InstagramAgent(object):
    def __init__(self, username, password):
        self.username = username
        self.password = password

    def like_instagram(self):
        driver = webdriver.Chrome('./chromedriver')
        driver.get(URL)
        driver.find_element_by_class_name('_b93kq').click()
        send_key = lambda x, y: driver.find_element_by_name(x).send_keys(y)
        send_key('username', self.username)
        send_key('password', self.password)
        driver.implicitly_wait(2)
        driver.find_elements_by_tag_name('button')[0].submit()
        for i in range(5):
            tags = driver.find_elements_by_class_name('coreSpriteHeartOpen')
            for tag in tags:
                tag.click()
            driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
            time.sleep(WAIT_LOADING_TIME)
        driver.quit()

    def like_instagram_loop(self, wait_time=WAIT_TIME):
        while True:
            self.like_instagram()
            time.sleep(wait_time)


if __name__ == '__main__':
    import fire
    fire.Fire(InstagramAgent)<commit_msg>add to catch KeyboardInterrupt exception.<commit_after>from selenium import webdriver
import time

URL = "https://www.instagram.com/?hl=ja"
WAIT_TIME = 1800
WAIT_LOADING_TIME = 5

class InstagramAgent(object):
    def __init__(self, username, password):
        self.username = username
        self.password = password

    def like_instagram(self):
        driver = webdriver.Chrome('./chromedriver')
        driver.get(URL)
        driver.find_element_by_class_name('_b93kq').click()
        send_key = lambda x, y: driver.find_element_by_name(x).send_keys(y)
        send_key('username', self.username)
        send_key('password', self.password)
        driver.implicitly_wait(2)
        driver.find_elements_by_tag_name('button')[0].submit()
        for i in range(5):
            tags = driver.find_elements_by_class_name('coreSpriteHeartOpen')
            for tag in tags:
                tag.click()
            driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
            time.sleep(WAIT_LOADING_TIME)
        driver.quit()

    def like_instagram_loop(self, wait_time=WAIT_TIME):
        try:
            while True:
                self.like_instagram()
                time.sleep(wait_time)
        except KeyboardInterrupt:
            print('interrupt')


if __name__ == '__main__':
    import fire
    fire.Fire(InstagramAgent)
{'fraction_non_alphanumeric': 0.1058868501529052, 'fraction_numerical': 0.008409785932721712, 'mean_word_length': 2.7492836676217767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4339358', 'n_tokens_mistral': 816, 'n_tokens_neox': 782, 'n_words': 141}