Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions Facebook/src/run_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep

class FaceBot:
def __init__(self,username,passwrd):
self.username = username
self.password = passwrd
self.url = 'https://facebook.com'
self.driver = webdriver.Chrome()

def login(self):
driver = self.driver
driver.get('{}'.format(self.url))
sleep(2)
driver.find_element_by_name('email').send_keys(self.username)
driver.find_element_by_name('pass').send_keys(self.password + Keys.RETURN)
sleep(4)

def Events(self):
sleep(1)
driver = self.driver
driver.get('{}/events'.format(self.url))

def Birthdays(self):
sleep(1)
driver = self.driver
driver.find_element_by_class_name('gs1a9yip ow4ym5g4 auili1gw rq0escxv j83agx80 cbu4d94t buofh1pr g5gj957u i1fnvgqd oygrvhab cxmmr5t8 hcukyx3x kvgmc6g5 tgvbjcpo hpfvmrgz rz4wbd8a a8nywdso l9j0dhe7 du4w35lb rj1gh0hx f10w8fjw pybr56ya').click()



def findfriend(self,person):
# """
# After login find a person on Facebook
# ...
#
# Attributes
# ----------
# self :
# class of Webdriver
# person : str
# username of person whose account you want to visit
#
# """
driver = self.driver
driver.get('{}/{}/'.format(self.url,person))

def like(self,amount):
# """
# Send a like on Facebook picture(s)
# ...
#
# Attributes
# ----------
# self :
# class of Webdriver
# amount : int
# the amount of pictures to like
#
# """
driver = self.driver
driver.find_element_by_class_name('eLAPa').click()
sleep(0.5)
i = 1
if amount > 1:
while (i <= amount):
driver.find_element_by_class_name('fr66n').click()
sleep(0.2)
driver.find_element_by_class_name('coreSpriteRightPaginationArrow').click()
sleep(1)
i += 1
else:
sleep(1)
driver.find_element_by_class_name('fr66n').click()

def comment(self,text,amount):
# """
# Send a comment on Facebook picture(s)
# ...
#
# Attributes
# ----------
# self :
# class of Webdriver
# text : str
# the text you want to comment (same for each picture)
# amount : int
# the amount of pictures to comment on
#
# """
driver = self.driver
driver.find_element_by_class_name('').click()
sleep(0.5)
i = 1
if amount > 1:
while (i <= amount):
driver.find_element_by_class_name('').click()
act = ActionChains(driver)
sleep(0.5)
act.send_keys(text + Keys.RETURN)
act.perform()
sleep(0.2)
driver.find_element_by_class_name('coreSpriteRightPaginationArrow').click()
sleep(1)
i += 1
else:
sleep(1)
driver.find_element_by_class_name('Ypffh').click()
act = ActionChains(driver)
sleep(0.5)
act.send_keys(text + Keys.RETURN)
act.perform()


face = FaceBot(username, passwrd)
face.login() # Login works
face.Events() # Direct to Events
face.Birthdays() # Working on - Go to Birthdays and post Happy Bday



44 changes: 35 additions & 9 deletions Instagram/src/run_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
import os

class InstaBot:
def __init__(self,username,passwrd):
Expand Down Expand Up @@ -52,7 +53,7 @@ def findfollower(self,person):
driver = self.driver
driver.get('{}/{}/'.format(self.url,person))

def like(self,amount):
def Like(self,amount):
# """
# Send a like on Instagram picture(s)
# ...
Expand Down Expand Up @@ -80,7 +81,7 @@ def like(self,amount):
sleep(1)
driver.find_element_by_class_name('fr66n').click()

def comment(self,text,amount):
def Comment(self,text,amount):
# """
# Send a comment on Instagram picture(s)
# ...
Expand Down Expand Up @@ -148,11 +149,36 @@ def like_comment_multi(self,text,amount):
driver.find_element_by_class_name('coreSpriteRightPaginationArrow').click()
sleep(1)
i += 1
amount = 2 # Amount of Likes/comments to give

insta = InstaBot('usrn', 'pswrd')
insta.login()
insta.findfollower('ljubeb')
#insta.like(amount)
#insta.comment('Nice picture!',amount)
insta.like_comment_multi('Nice picture!',amount)
if __name__ == '__main__':

usr = str(input('What is your Instagram username? (case sensitive)'))
paswrd = str(input('What is your Instagram password (case sensitive'))
insta = InstaBot(usr, paswrd)

person = str(input('Input the username of the person who you like to find: '))
What = str(input('Would you like to Like (L), Comment (C) or Both (B)?: ').lower())

if What == 'l' or What == 'c' or What == 'b':
pass
else:
print('Sorry not valid input.')

if What == 'l':
amount = int(input('How many photos do you want to like? '))
insta.login()
insta.findfollower(person)
insta.Like(amount)
elif What == 'c':
comment = str(input('What would you like to comment? '))
amount = int(input('How many photos do you want to commant that on? '))
insta.login()
insta.findfollower(person)
insta.Comment(comment,amount)
elif What == 'b':
amount = int(input('How many photos do you want to like and comment on? '))
comment = str(input('What would you like to comment? '))
insta.login()
insta.findfollower(person)
insta.like_comment_multi(comment,amount)