Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3. import time
  4.  
  5. class InstagramBot:
  6. def __init__(self,username,password):
  7. self.username = username
  8. self.password = password
  9. self.bot = webdriver.Firefox(executable_path = '/Users/Marc/Downloads/geckodriver.exe')
  10.  
  11. def login(self):
  12. bot = self.bot
  13. bot.get('https://www.instagram.com/accounts/login/')
  14. time.sleep(3)
  15. email = bot.find_element_by_name('username').send_keys(self.username)
  16. password = bot.find_element_by_name('password').send_keys(self.password + Keys.RETURN)
  17.  
  18. time.sleep(3)
  19.  
  20. def searchHashtag(self,hashtag):
  21. bot = self.bot
  22.  
  23. bot.get('https://www.instagram.com/explore/tags/' + hashtag)
  24.  
  25. def likePhotos(self,amount):
  26. bot = self.bot
  27.  
  28. bot.find_element_by_class_name('v1Nh3').click()
  29.  
  30. i = 1
  31. while i <= amount:
  32. time.sleep(1)
  33. bot.find_element_by_class_name('fr66n').click()
  34. bot.find_element_by_class_name('coreSpriteRightPaginationArrow').click()
  35. time.sleep(1)
  36.  
  37. i += 1
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. insta = InstagramBot('YOUR_USERNAME', 'YOUR_PASSWORD')
  45. insta.login()
  46. insta.searchHashtag('HASHTAG_YOU_WANT_TO_SEARCH')
  47. insta.likePhotos(NUMBER_OF_PHOTOS_TO_LIKE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement