Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- #Instagram Direct Message
- x = 0
- with open('usrs.txt','r') as u:
- user = [line.strip() for line in u]
- def dmer():
- global x
- usrnames = user # username whom you will send the message
- Options = webdriver.ChromeOptions()
- mobile_emulation = {
- "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" }
- Options.add_experimental_option("mobileEmulation", mobile_emulation)
- Options.add_argument("--log-level=3")
- bot = webdriver.Chrome(options=Options, executable_path="chromedriver.exe")
- bot.set_window_size(500, 768)
- bot.get('https://www.instagram.com/accounts/login/')
- time.sleep(10)
- usrname_bar = bot.find_element_by_name('username')
- passwrd_bar = bot.find_element_by_name('password')
- username = '' # Enter your username here
- password = '' # Enter your password here
- usrname_bar.send_keys(username)
- passwrd_bar.send_keys(password + Keys.ENTER)
- time.sleep(10)
- def send_msg(user):
- bot.get('https://www.instagram.com/direct/new/')
- time.sleep(5)
- to_btn = bot.find_element_by_name('queryBox')
- to_btn.send_keys(user)
- time.sleep(8)
- chk_mrk = bot.find_element_by_class_name('wpO6b ')
- chk_mrk.click()
- time.sleep(3)
- nxt_btn = bot.find_element_by_xpath('//div[@class="mXkkY KDuQp"]')
- nxt_btn.click()
- time.sleep(6)
- txt_box = bot.find_element_by_tag_name('textarea')
- 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
- time.sleep(2)
- snd_btn = bot.find_elements_by_css_selector('.sqdOP.yWX7d.y3zKF')
- snd_btnn = snd_btn[len(snd_btn)-1]
- snd_btnn.click()
- time.sleep(30)
- count = 0
- try:
- for usrnamee in usrnames:
- send_msg(usrnamee)
- count += 1
- except TypeError:
- print('Failed!')
- bot.quit()
- print(f'''
- Successfully Sent {count} Massages
- ''')
- dmer()
Advertisement
Add Comment
Please, Sign In to add comment