├── .gitattributes ├── Python.pdf ├── instabot ├── chromedriver.exe ├── __pycache__ │ └── bot.cpython-36.pyc ├── mainbot └── bot.py └── semplice gioco in python.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Python.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectoOfficial/Python-e-Teoria-sui-linguaggi-dinamici/master/Python.pdf -------------------------------------------------------------------------------- /instabot/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectoOfficial/Python-e-Teoria-sui-linguaggi-dinamici/master/instabot/chromedriver.exe -------------------------------------------------------------------------------- /instabot/__pycache__/bot.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProjectoOfficial/Python-e-Teoria-sui-linguaggi-dinamici/master/instabot/__pycache__/bot.cpython-36.pyc -------------------------------------------------------------------------------- /instabot/mainbot: -------------------------------------------------------------------------------- 1 | from instabot import bot 2 | 3 | username = 'nome utente' 4 | password = 'la tua password' 5 | profile = 'profilo target' 6 | 7 | stop = 0 8 | start = 5 9 | 10 | bot = bot.InstaBot(username, password) 11 | bot.work_sequentially(profile,stop,start) -------------------------------------------------------------------------------- /semplice gioco in python.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import random 3 | from time import time 4 | #import pkg_resources.py2_warn 5 | 6 | if __name__ == '__main__': 7 | 8 | pygame.init() 9 | win = pygame.display.set_mode((500, 500)) 10 | pygame.display.set_caption("first game") 11 | FPS = 60 12 | clock = pygame.time.Clock() 13 | 14 | pygame.font.init() 15 | myfont = pygame.font.SysFont('Comic Sans MS', 30) 16 | 17 | x = 0 18 | y = 0 19 | w = 50 20 | h = 50 21 | v = 10 22 | 23 | x1 = random.randrange(500 - w) 24 | y1 = random.randrange(500 - h) 25 | 26 | punti = 0 27 | 28 | start_time = time() 29 | run = True 30 | while run: 31 | pygame.time.delay(100) 32 | for event in pygame.event.get(): 33 | if event.type == pygame.QUIT: 34 | run = False 35 | 36 | keys = pygame.key.get_pressed() 37 | 38 | if keys[pygame.K_LEFT] and x > 0: 39 | x -= v 40 | if keys[pygame.K_RIGHT] and x < 500 - 50: 41 | x += v 42 | if keys[pygame.K_UP] and y > 0: 43 | y -= v 44 | if keys[pygame.K_DOWN] and y < 500 - 50: 45 | y += v 46 | 47 | end_time = time() 48 | if end_time - start_time >= 8: 49 | x1 = random.randrange(500 - w) 50 | y1 = random.randrange(500 - h) 51 | start_time = time() 52 | 53 | pygame.display.set_caption("punteggio: {}".format(punti)) 54 | if x1 in range(x - v, x + v) and y1 in range(y - v, y + v): 55 | punti += 1 56 | x1 = random.randrange(500 - w) 57 | y1 = random.randrange(500 - h) 58 | 59 | win.fill((0, 0, 0)) 60 | pygame.draw.rect(win, (255, 0, 0), (x, y, w, h)) 61 | pygame.draw.rect(win, (0, 255, 0), (x1, y1, w, h)) 62 | pygame.display.update() 63 | clock.tick(FPS) 64 | pygame.quit() -------------------------------------------------------------------------------- /instabot/bot.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from time import sleep 3 | from random import randrange 4 | 5 | 6 | class InstaBot: 7 | def __init__(self, username, password): 8 | self.driver = webdriver.Chrome() 9 | self.username = username 10 | self.totlikes = 0 11 | 12 | self.driver.get("https://instagram.com") 13 | sleep(2) 14 | self.driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div[2]/button[1]').click() 15 | login_field = self.driver.find_element_by_xpath("//input[@name=\"username\"]").send_keys(username) 16 | password_field = self.driver.find_element_by_xpath("//input[@name=\"password\"]").send_keys(password) 17 | self.driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[3]/button/div').click() 18 | sleep(2) 19 | code = input("insert code") 20 | self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div[1]/div/form/div[1]/div/label/input').send_keys(code) 21 | sleep(1) 22 | self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div/div[1]/div/form/div[2]/button').click() 23 | sleep(5) 24 | self.driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/div/div/section/div/button').click() 25 | sleep(5) 26 | self.driver.find_element_by_xpath('/html/body/div[4]/div/div/div/div[3]/button[2]').click() 27 | sleep(2) 28 | 29 | def work_randomly(self, profile, stop=100, start=0): 30 | n = start 31 | number_list = [] 32 | rand_number = 0 33 | while True: 34 | 35 | #barra di ricerca 36 | self.driver.get("https://instagram.com/{}".format(profile)) 37 | sleep(2) 38 | 39 | #entra nei follower 40 | self.driver.find_element_by_xpath( 41 | '//*[@id="react-root"]/section/main/div/header/section/ul/li[2]/a').click() 42 | sleep(2) 43 | 44 | 45 | 46 | last_ht,ht = 0,1 47 | scroll_box = self.driver.find_element_by_xpath("/html/body/div[5]/div/div/div[2]") 48 | 49 | # entra nel profilo di un follower random 50 | while True: 51 | rand_number = randrange(start, stop, 1) #start,stop,step 52 | if rand_number not in number_list: 53 | number_list.append(rand_number) 54 | break 55 | 56 | print("user to find: {}".format(rand_number)) 57 | while True: 58 | try: 59 | self.driver.find_element_by_xpath( 60 | '/html/body/div[5]/div/div/div[2]/ul/div/li[{}]/div/div[2]/div[1]/div/div/span/a'.format(rand_number)).click() 61 | print("Found!") 62 | break 63 | except Exception: 64 | pass 65 | 66 | try: 67 | ht = self.driver.execute_script(""" 68 | arguments[0].scrollTo({},{}); 69 | return arguments[0].scrollHeight""".format(ht,ht+10), scroll_box) 70 | 71 | except Exception: 72 | break 73 | sleep(1.5) 74 | 75 | sleep(3) 76 | 77 | 78 | #prende la prima foto 79 | try: 80 | self.driver.find_element_by_xpath('/html/body/div[1]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]/a/div/div[2]').click() 81 | print("getting the picture") 82 | except Exception: 83 | pass 84 | sleep(1.4) 85 | 86 | # mette like 87 | try: 88 | self.driver.find_element_by_xpath('/html/body/div[5]/div[2]/div/article/div[3]/section[1]/span[1]/button').click() 89 | print("pushing like") 90 | self.totlikes += 1 91 | print("total likes done until now: {}".format(self.totlikes)) 92 | except Exception: 93 | pass 94 | sleep(1.4) 95 | 96 | n += 1 97 | 98 | if n == stop: 99 | print("process finished") 100 | print("total number of likes done: {}".format(self.totlikes)) 101 | print("Last user number: {}".format(n)) 102 | break 103 | 104 | def work_sequentially(self, profile, stop=100, start=0): 105 | n = start 106 | while True: 107 | # barra di ricerca 108 | self.driver.get("https://instagram.com/{}".format(profile)) 109 | sleep(2) 110 | 111 | # entra nei follower 112 | self.driver.find_element_by_xpath( 113 | '//*[@id="react-root"]/section/main/div/header/section/ul/li[2]/a').click() 114 | sleep(2) 115 | 116 | last_ht, ht = 0, 1 117 | scroll_box = self.driver.find_element_by_xpath("/html/body/div[5]/div/div/div[2]") 118 | # entra nel profilo di un follower random 119 | 120 | 121 | print("user to find: {}".format(n)) 122 | while True: 123 | try: 124 | self.driver.find_element_by_xpath( 125 | '/html/body/div[5]/div/div/div[2]/ul/div/li[{}]/div/div[2]/div[1]/div/div/span/a'.format( 126 | n)).click() 127 | print("Found!") 128 | break 129 | except Exception: 130 | pass 131 | 132 | try: 133 | ht = self.driver.execute_script(""" 134 | arguments[0].scrollTo({},{}); 135 | return arguments[0].scrollHeight""".format(ht, ht + 10), scroll_box) 136 | 137 | except Exception: 138 | break 139 | sleep(1.5) 140 | 141 | sleep(3) 142 | 143 | try: 144 | # prende la prima foto 145 | self.driver.find_element_by_xpath( 146 | '/html/body/div[1]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]/a/div/div[2]').click() 147 | print("getting the picture") 148 | except Exception: 149 | pass 150 | sleep(2) 151 | 152 | # mette like 153 | try: 154 | 155 | self.driver.find_element_by_xpath( 156 | '/html/body/div[5]/div[2]/div/article/div[3]/section[1]/span[1]/button').click() 157 | print("pushing like") 158 | self.totlikes += 1 159 | print("total likes done until now: {}".format(self.totlikes)) 160 | except Exception: 161 | pass 162 | sleep(2) 163 | 164 | n += 1 165 | 166 | if n == stop: 167 | print("process finished") 168 | print("total number of likes done: {}".format(self.totlikes)) 169 | print("Last user number: {}".format(n)) 170 | break 171 | 172 | 173 | 174 | 175 | 176 | 177 | --------------------------------------------------------------------------------