DonEros

Untitled

May 25th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. import time
  2.  
  3. from selenium import webdriver
  4. from selenium.webdriver.common.keys import Keys
  5.  
  6. #Instagram Direct Message
  7.  
  8. x = 0
  9.  
  10. with open('usrs.txt','r') as u:
  11. user = [line.strip() for line in u]
  12.  
  13. def dmer():
  14. global x
  15.  
  16. usrnames = user # username whom you will send the message
  17.  
  18. Options = webdriver.ChromeOptions()
  19.  
  20. mobile_emulation = {
  21. "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/101.0.4951.64 Mobile Safari/535.19" }
  22.  
  23. Options.add_experimental_option("mobileEmulation", mobile_emulation)
  24. Options.add_argument("--log-level=3")
  25.  
  26. bot = webdriver.Chrome(options=Options, executable_path="chromedriver.exe")
  27. bot.set_window_size(500, 768)
  28.  
  29. bot.get('https://www.instagram.com/accounts/login/')
  30.  
  31. time.sleep(10)
  32.  
  33. usrname_bar = bot.find_element_by_name('username')
  34. passwrd_bar = bot.find_element_by_name('password')
  35.  
  36. username = '' # Enter your username here
  37. password = '' # Enter your password here
  38.  
  39. usrname_bar.send_keys(username)
  40. passwrd_bar.send_keys(password + Keys.ENTER)
  41.  
  42. time.sleep(10)
  43.  
  44. def send_msg(user):
  45. bot.get('https://www.instagram.com/direct/new/')
  46.  
  47. time.sleep(5)
  48.  
  49. to_btn = bot.find_element_by_name('queryBox')
  50. to_btn.send_keys(user)
  51.  
  52. time.sleep(8)
  53.  
  54. chk_mrk = bot.find_element_by_class_name('wpO6b ')
  55. chk_mrk.click()
  56.  
  57. time.sleep(3)
  58.  
  59. nxt_btn = bot.find_element_by_xpath('//div[@class="mXkkY KDuQp"]')
  60. nxt_btn.click()
  61.  
  62. time.sleep(6)
  63.  
  64. txt_box = bot.find_element_by_tag_name('textarea')
  65. txt_box.send_keys(f"Hey @{user}, I'm Jordan from ARICCI’s Talent Recruitment in London.\nWe’re an upcoming sunglasses brand and we would love to see you in our new pieces!\n\nWould you be down for promoting us and earning FREE products, BIG commissions, and getting featured on our official Instagram page?\n\n DM us @ariccirecruiter to get started! Offer runs out in 48 hours.") # Customize your message
  66.  
  67. time.sleep(2)
  68.  
  69. snd_btn = bot.find_elements_by_css_selector('.sqdOP.yWX7d.y3zKF')
  70. snd_btnn = snd_btn[len(snd_btn)-1]
  71. snd_btnn.click()
  72.  
  73. time.sleep(30)
  74.  
  75. count = 0
  76. try:
  77. for usrnamee in usrnames:
  78. send_msg(usrnamee)
  79. count += 1
  80.  
  81. except TypeError:
  82. print('Failed!')
  83.  
  84. bot.quit()
  85.  
  86. print(f'''
  87. Successfully Sent {count} Massages
  88. ''')
  89.  
  90. dmer()
Advertisement
Add Comment
Please, Sign In to add comment