Advertisement
Guest User

Untitled

a guest
Apr 15th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. from selenium import webdriver
  2. from time import sleep as s
  3. from math import ceil
  4. import pyautogui as p
  5.  
  6.  
  7. username = "thetravelingfraternity"
  8. password = "Traveling17"
  9.  
  10. #
  11. # ----------------------------------------------------------------------------------------------------------------------
  12. # ----------------------------------------------------------------------------------------------------------------------
  13. # -----------------------------------------------------INIT-------------------------------------------------------------
  14. driver = webdriver.Chrome()
  15. driver.get("https://www.instagram.com/")
  16. element = driver.find_element_by_css_selector('a._fcn8k')
  17. element.click()
  18. # -----------------------------------------------------END INIT---------------------------------------------------------
  19.  
  20.  
  21. #
  22. # ----------------------------------------------------------------------------------------------------------------------
  23. # ----------------------------------------------------------------------------------------------------------------------
  24. # -----------------------------------------------------LOGIN------------------------------------------------------------
  25. element = driver.find_element_by_css_selector(
  26. "#react-root > section > main > article > div._p8ymb > div:nth-child(1) > div > form > div:nth-child(1) > input")
  27. element.send_keys(username)
  28.  
  29. element = driver.find_element_by_css_selector(
  30. "#react-root > section > main > article > div._p8ymb > div:nth-child(1) > div > form > div:nth-child(2) > input")
  31. element.send_keys(password)
  32.  
  33. element = driver.find_element_by_css_selector(
  34. "#react-root > section > main > article > div._p8ymb > div:nth-child(1) > div > form > span > button")
  35. element.click(); s(1)
  36. # -----------------------------------------------------END LOGIN--------------------------------------------------------
  37.  
  38.  
  39. #
  40. # ----------------------------------------------------------------------------------------------------------------------
  41. # ----------------------------------------------------------------------------------------------------------------------
  42. # -----------------------------------------------------HOME SCREEN------------------------------------------------------
  43. # CLICK OUT
  44. s(1)
  45. for _ in range(20):
  46. p.click()
  47.  
  48. # SELECT USER PROFILE ICON
  49. element = driver.find_element_by_css_selector(
  50. "#react-root > section > nav > div > div > div > div._nhei4 > div > div:nth-child(3) > a")
  51. element.click()
  52. # -----------------------------------------------------END HOME SCREEN--------------------------------------------------
  53.  
  54.  
  55. #
  56. # ----------------------------------------------------------------------------------------------------------------------
  57. # ----------------------------------------------------------------------------------------------------------------------
  58. # -----------------------------------------------------USER PROFILE-----------------------------------------------------
  59. s(1)
  60. for _ in range(2):
  61. p.click(720, 320)
  62. # -----------------------------------------------------END USER PROFILE-------------------------------------------------
  63.  
  64.  
  65. #
  66. # ----------------------------------------------------------------------------------------------------------------------
  67. # ----------------------------------------------------------------------------------------------------------------------
  68. # -----------------------------------------------------FOLLOWING--------------------------------------------------------
  69. s(1)
  70. OFFSET_X = 40
  71. OFFSET_Y = 20
  72. following_coordinates = p.locateAllOnScreen('following_button.png')
  73. for c in following_coordinates:
  74. x,y = c[0], c[1]
  75. p.click(ceil(x/2)+OFFSET_X, ceil(y/2)+OFFSET_Y)
  76. s(.5)
  77. driver.close()
  78. # -----------------------------------------------------END FOLLOWING----------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement