-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpvoteDownvote.py
66 lines (44 loc) · 1.6 KB
/
UpvoteDownvote.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
# upvote
from selenium import webdriver
from time import sleep
from Utilities import remove_prefix, comment_list
from random import randint
"""
upvote and downvote selected posts
"""
def post_upvote(driver):
sleep(1.5)
upvote_button = driver.find_element_by_xpath('/html/body/div[1]/div/div[2]/div[3]/div/div/div/div[1]/div/div[1]/div[1]/button[1]')
sleep(0.5)
upvote_status = upvote_button.get_attribute('aria-pressed')
try:
if upvote_status == "false":
sleep(0.5)
upvote_button.click()
print('post upvoted!')
except:
print('unable to upvote this post')
sleep(2)
def post_downvote(driver):
sleep(1.5)
downvote_button = driver.find_element_by_xpath(' //div[@class = "_1rZYMD_4xY3gRcSS3p8ODO"]//following-sibling::button')
sleep(0.5)
downvote_status = downvote_button.get_attribute('aria-pressed')
try:
if downvote_status == "false":
sleep(0.5)
downvote_button.click()
except:
print('unable to upvote this post')
sleep(2)
# if we are blocked by the site from commenting skip to another post
def post_comment(driver):
random_index = randint(0,15)
comment = comment_list[random_index]
sleep(2)
comment_box = driver.find_element_by_xpath('//div[@class ="notranslate public-DraftEditor-content"]')
comment_box.send_keys(comment)
sleep(4)
comment_confirm = driver.find_element_by_xpath('//*[@id="overlayScrollContainer"]/div[2]/div[1]/div[2]/div[2]/div[2]/div/div/div[3]/div[1]/button')
comment_confirm.click()
sleep(2)