-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvk_posting.py
62 lines (55 loc) · 1.97 KB
/
vk_posting.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
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
from time import sleep
import requests
##Чтение ссылки из текстового файла
f = open('blogurl.txt', 'r')
blogurl = f.readline()
blogurl=blogurl+' '
kolbs = len(blogurl)
print ('Blog url: '+blogurl)
print("\nConnection success...")
## настройки мозила
options = Options()
options.headless = True
driver = webdriver.Firefox(executable_path=r"C:/test/geckodriver.exe")
driver.maximize_window()
#Вход в соцсеть
driver.get("http://vk.com")
sleep(5)
driver.find_element_by_id("index_email").send_keys('+37511111111111')##вместо yourlogin вводин свой логин или номер телефона
sleep(2)
pwd = driver.find_element_by_id("index_pass")
pwd.send_keys('1111111')# Вводим пароль вместо YoUrPaSSwOrD
pwd.send_keys(Keys.ENTER)
sleep(7)
driver.implicitly_wait(30)
with open("1.txt", "r", encoding="utf-8") as file:
for line in file:
URL = line.strip()
driver.get(URL)
sleep(7)
e = driver.find_element_by_id("post_field")
e.clear()
act = ActionChains(driver)
act.move_to_element(e).perform()
act = ActionChains(driver)
act.click(e).perform()
sleep(3)
act = ActionChains(driver)
act.send_keys(blogurl).perform()
sleep(3)
for _ in range(kolbs):
act = ActionChains(driver)
act.send_keys(Keys.BACKSPACE).perform()
driver.find_element_by_id("send_post").click()
sleep(3)
#закрываем браузер
driver.close()