-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
86 lines (61 loc) · 2.49 KB
/
main.py
File metadata and controls
86 lines (61 loc) · 2.49 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from FacebookAutoComment import Browser, FacebookCommenting
from time import sleep
from getpass import getpass
def my_intro():
print(" Automation of facebook comment by h3ck(Samrat).",
end="\n\n")
if __name__ == "__main__":
try:
my_intro()
previousSetsOfTabs = set()
setOfCommentTabs = set()
currentSet = set()
email = input("Email: ")
password = getpass()
print("Logging in...")
browser = Browser().openChrome()
facebook = FacebookCommenting(browser, email, password)
facebook.openFacebook()
facebook.login()
sleep(6)
desiredComment = (input(
"\nEnter the comment you want to be automated (default: #StopVoilenceOnHuman): "
) or "#StopVoilenceOnHuman")
desiredPage = input(
"Enter url of the desire page you want to comment on (default : On your facebook homepage)\n Example : https://www.facebook.com/username/ \n==> "
)
if desiredPage != "\n":
facebook.switchPage(desiredPage)
sleep(5)
print("Opened page...")
print("To end press Ctrl + C")
commentTabs = facebook.selectComment()
setOfCommentTabs = set(commentTabs)
currentSet = setOfCommentTabs.difference(previousSetsOfTabs)
previousSetsOfTabs.update(currentSet)
facebook.comment(currentSet, desiredComment)
SCROLL_PAUSE_TIME = 5
last_height = browser.execute_script(
"return document.body.scrollHeight")
while True:
# Scroll down to bottom
browser.execute_script(
"window.scrollTo(0, document.body.scrollHeight)")
# Wait to load page
sleep(SCROLL_PAUSE_TIME)
# Calculate new scroll height and compare with last scroll height
new_height = browser.execute_script(
"return document.body.scrollHeight")
if new_height == last_height:
break
last_height = new_height
commentTabs = facebook.selectComment()
#updating the database in set
setOfCommentTabs = set(commentTabs)
currentSet = setOfCommentTabs.difference(previousSetsOfTabs)
facebook.comment(currentSet, desiredComment)
#updates the used post to comment
previousSetsOfTabs.update(currentSet)
except KeyboardInterrupt:
print('Caught KeyboardInterrupt')
browser.quit()