-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotcp.py
70 lines (67 loc) · 2.67 KB
/
botcp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from selenium import webdriver
from selenium.webdriver.chrome.options import *
from selenium.webdriver.common.keys import Keys
import autoit
import time
import bot
bot.ext()
username = "2days_leonardo"
passwd = "Leonardo1522"
driverpth = "chromedriver.exe"
photopath = "img.jpg" #examp "C:\\Users\\alire\\PycharmProjects\\instagrambot2\\logo.png"
phototext = "plesssss"
options = Options()
options.add_argument("--log-level=3")
options.add_argument("--silent")
#options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-logging")
options.add_argument("--mute-audio")
#mobile_emulation = {"deviceName": "Nexus 5"}
#options.add_experimental_option("mobileEmulation", mobile_emulation)
options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1')
driver = webdriver.Chrome(executable_path=driverpth,options=options)
driver.get("https://www.instagram.com/accounts/login/?hl=tr")
time.sleep(3)
driver.find_element_by_xpath("//*[@id='react-root']/section/main/article/div/div/div/form/div[4]/div/label/input").send_keys(username)
time.sleep(0.5)
driver.find_element_by_xpath("//*[@id='react-root']/section/main/article/div/div/div/form/div[5]/div/label/input").send_keys(passwd)
time.sleep(0.5)
driver.find_element_by_xpath("//*[@id='react-root']/section/main/article/div/div/div/form/div[7]/button/div").click()
while 1:
time.sleep(1)
try:
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/button").click()
break
except:
pass
while 1:
time.sleep(1)
try:
driver.find_element_by_xpath("/html/body/div[3]/div/div/div[3]/button[2]").click()
break
except:
pass
while 1:
time.sleep(1)
driver.find_element_by_css_selector('body').send_keys(Keys.PAGE_DOWN)
try:
driver.find_element_by_xpath("/html/body/div[3]/div/div/div[3]/button[2]").click()
break
except:
pass
driver.find_element_by_xpath("//div[@role='menuitem']").click()
time.sleep(1.5)
autoit.win_active("Open") #open can change by your os language if not open change that
time.sleep(2)
autoit.control_send("Open", "Edit1", photopath)
time.sleep(1.5)
autoit.control_send("Open", "Edit1", "{ENTER}")
time.sleep(2)
driver.find_element_by_xpath("//*[@id='react-root']/section/div[1]/header/div/div[2]/button").click()
time.sleep(1)
driver.find_element_by_xpath("//*[@id='react-root']/section/div[2]/section[1]/div[1]/textarea").send_keys(phototext)
time.sleep(1)
driver.find_element_by_xpath("//*[@id='react-root']/section/div[1]/header/div/div[2]/button").click()
time.sleep(4)
driver.close()