示例#1
0
 def next_post(self, i):
     if i == 2:
         UsualFunctions().click_btn(self.driver,
                                    '/html/body/div[4]/div[1]/div/div/a')
     else:
         UsualFunctions().click_btn(
             self.driver, '/html/body/div[4]/div[1]/div/div/a[2]')
示例#2
0
 def insert_user(self):
     time.sleep(2)
     try:
         user_field = UsualFunctions().find_element(
             self.driver,
             '//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[2]/div/label/input'
         )
         user_field.click()
         user_field.send_keys(self.user)
     except:
         UsualFunctions().error(self.driver, 'insert login')
示例#3
0
 def insert_pass(self):
     try:
         pass_field = UsualFunctions().find_element(
             self.driver,
             '//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[3]/div/label/input'
         )
         pass_field.click()
         pass_field.send_keys(self.password)
         UsualFunctions().click_btn(
             self.driver,
             '/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[4]/button'
         )
         time.sleep(4)
     except:
         UsualFunctions().error(self.driver, 'insert password')
示例#4
0
def run_bot(user, password, option):
    if option == 1:
        target = UsualFunctions().get_target()
        bot = login(user, password)
        bot.target = target
        bot.like_all()
    elif option == 2:
        target = UsualFunctions().get_target()
        num_posts = UsualFunctions().get_num_posts_to_like()
        bot = login(user, password)
        bot.target = target
        bot.like_some(num_posts)
    else:
        link = UsualFunctions().get_link()
        bot = login(user, password)
        bot.like_one(link)
示例#5
0
 def get_num_posts(self):
     try:
         qnt = UsualFunctions().find_element(
             self.driver,
             '/html/body/div[1]/section/main/div/header/section/ul/li[1]/span/span'
         ).text
         qnt = qnt.replace('.', '')
         qnt = int(qnt)
     except:
         UsualFunctions().error(self.driver, "like posts")
         return 0
     else:
         if qnt == 0:
             UsualFunctions().error(
                 self.driver,
                 "like posts. Because there's no post to like :/")
             return 0
         else:
             return qnt
示例#6
0
 def like(self, i):
     try:
         WebDriverWait(self.driver, 10).until(
             EC.element_to_be_clickable((
                 By.XPATH,
                 "/html/body/div[4]/div[2]/div/article/div[2]/section[1]/span[1]/button"
             ))).click()
     except:
         UsualFunctions().error(self.driver, f'like {i}º post')
     else:
         print(f'{i}º post liked successfully!')
示例#7
0
def login(user, password):
    # set driver
    driver = UsualFunctions().set_driver()

    # instance & login
    bot = LoginInsta(driver, user, password)
    bot.open_page()
    bot.insert_user()
    bot.insert_pass()
    bot.driver = driver
    return bot
示例#8
0
 def like_one(self, link):
     self.driver.get(link)
     time.sleep(3)
     try:
         WebDriverWait(self.driver, 10).until(
             EC.element_to_be_clickable((
                 By.XPATH,
                 '//*[@id="react-root"]/section/main/div/div[1]/article/div[2]/section[1]/span[1]/button'
             ))).click()
     except:
         UsualFunctions().error(self.driver, 'like the post')
     else:
         print('Post liked successfully!')
示例#9
0
    def like_some(self, num_posts):
        self.driver.get(f'https://www.instagram.com/{self.target}/')
        time.sleep(3)
        profile_posts = self.get_num_posts()

        if num_posts < profile_posts:
            for i in range(1, num_posts + 1):
                try:
                    if i == 1:
                        self.open_post()
                    else:
                        self.next_post(i)
                except:
                    UsualFunctions().error(self.driver, 'detect post')
                else:
                    self.like(i)
                    time.sleep(1)
            print(f'{num_posts} posts liked successfully!')
        else:
            UsualFunctions().error(
                self.driver,
                'Number of posts grater than profile number of posts')
示例#10
0
    def like_all(self):
        self.driver.get(f'https://www.instagram.com/{self.target}/')
        time.sleep(3)

        num_posts = self.get_num_posts()
        if num_posts > 0:
            print(f'{num_posts} posts to like!')
            for i in range(1, num_posts + 1):
                try:
                    if i == 1:
                        self.open_post()
                    else:
                        self.next_post(i)
                except:
                    UsualFunctions().error(self.driver, 'detect post')
                else:
                    self.like(i)
                    time.sleep(1)
        else:
            print('Maybe this account has no posts to like!')
示例#11
0
from target import Target
from usuals import UsualFunctions


def run_bot(user, password, option):
    if option == 1:
        target = UsualFunctions().get_target()
        bot = login(user, password)
        bot.target = target
        bot.like_all()
    elif option == 2:
        target = UsualFunctions().get_target()
        num_posts = UsualFunctions().get_num_posts_to_like()
        bot = login(user, password)
        bot.target = target
        bot.like_some(num_posts)
    else:
        link = UsualFunctions().get_link()
        bot = login(user, password)
        bot.like_one(link)


# get option
option = UsualFunctions().show_options()

# get user credentials
user, password = UsualFunctions().get_cred()

# run the bot
run_bot(user, password, option)
示例#12
0
def create_dashboard():
    white = '#FFFFFF'
    black = '#151515'
    red = "#9D0208"
    green = '#08A045'

    tela = Tk()
    tela.title('Dashboard')
    tela.geometry("750x480")
    tela.resizable(False, False)
    tela['background'] = black

    ## PORCENTAGENS
    total_ativos = int(UsualFunctions().get_active_cases().replace('.', ''))
    mild = int(UsualFunctions().get_mild_conditions().replace('.', ''))
    serious = int(UsualFunctions().get_serious_conditions().replace('.', ''))

    mild = (mild / total_ativos) * 100
    serious = (serious / total_ativos) * 100

    ## DATA
    hoje = datetime.now()
    data = f'{"%02d" % hoje.day}/{"%02d" % hoje.month}/{hoje.year}'

    ## HEADER
    titulo1 = Label(tela,
                    text='Covid-19',
                    font='Impact 40',
                    bg=black,
                    fg=white)
    titulo1.place(relx=0.5, rely=0.05, anchor=CENTER)

    titulo2 = Label(tela, text='Tracker', font='Impact 40', bg=black, fg=white)
    titulo2.place(relx=0.5, rely=0.18, anchor=CENTER)

    subtitulo = Label(tela,
                      text='Dados da covid-19 no Brasil em tempo real',
                      font='Roboto 16',
                      bg=black,
                      fg=green)
    subtitulo.place(relx=0.5, rely=0.27, anchor=CENTER)

    data_label = Label(tela, text=data, font='Roboto 12', bg=black, fg=white)
    data_label.place(relx=0.5, rely=0.32, anchor=CENTER)

    ## INFO
    casos_label = Label(tela,
                        text="Total de casos:",
                        font='Roboto 20',
                        bg=black,
                        fg=white)
    casos_label.place(relx=0.05, rely=0.4, anchor='w')

    casos_number = Label(tela,
                         text=UsualFunctions().get_cases(),
                         font='Roboto 30 bold',
                         bg=black,
                         fg=red)
    casos_number.place(relx=0.45, rely=0.4, anchor='w')

    recuperados_label = Label(tela,
                              text="Total de recuperados:",
                              font='Roboto 20',
                              bg=black,
                              fg=white)
    recuperados_label.place(relx=0.05, rely=0.5, anchor='w')

    recuperados_number = Label(tela,
                               text=UsualFunctions().get_recovered(),
                               font='Roboto 30 bold',
                               bg=black,
                               fg=green)
    recuperados_number.place(relx=0.45, rely=0.5, anchor='w')

    mortes_label = Label(tela,
                         text="Total de mortes:",
                         font='Roboto 20',
                         bg=black,
                         fg=white)
    mortes_label.place(relx=0.05, rely=0.6, anchor='w')

    mortes_number = Label(tela,
                          text=UsualFunctions().get_deaths(),
                          font='Roboto 30 bold',
                          bg=black,
                          fg=red)
    mortes_number.place(relx=0.45, rely=0.6, anchor='w')

    ativos_label = Label(tela,
                         text="Total de casos ativos:",
                         font='Roboto 20',
                         bg=black,
                         fg=white)
    ativos_label.place(relx=0.05, rely=0.7, anchor='w')

    ativos_number = Label(tela,
                          text=UsualFunctions().get_active_cases(),
                          font='Roboto 30 bold',
                          bg=black,
                          fg=white)
    ativos_number.place(relx=0.45, rely=0.7, anchor='w')

    casos_leves_label = Label(tela,
                              text="dos ativos apresentam condições leves",
                              font='Roboto 13',
                              bg=black,
                              fg=white)
    casos_leves_label.place(relx=0.05, rely=0.95, anchor='w')

    casos_leves_number = Label(tela,
                               text=f'{"%.1f" % mild}%',
                               font='Roboto 30 bold',
                               bg=black,
                               fg=green)
    casos_leves_number.place(relx=0.2, rely=0.85, anchor='w')

    casos_graves_label = Label(tela,
                               text="dos ativos apresentam condições graves",
                               font='Roboto 13',
                               bg=black,
                               fg=white)
    casos_graves_label.place(relx=0.55, rely=0.95, anchor='w')

    casos_graves_number = Label(tela,
                                text=f'{"%.1f" % serious}%',
                                font='Roboto 30 bold',
                                bg=black,
                                fg=red)
    casos_graves_number.place(relx=0.7, rely=0.85, anchor='w')

    tela.mainloop()
示例#13
0
 def open_post(self):
     UsualFunctions().click_btn(
         self.driver,
         '//*[@id="react-root"]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]/a/div[1]/div[2]'
     )