-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.py
90 lines (72 loc) · 2.45 KB
/
app.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from selenium import webdriver
from time import sleep
from flask import Flask, render_template, request
from werkzeug import secure_filename
from selenium.webdriver.chrome.options import Options
import os
def Facebook(usr,pwd,path,desc,speed):
if usr:
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path = './chromedriver.exe', chrome_options = chrome_options)
#<--- code to login --->
driver.get('https://en-gb.facebook.com/login')
usr_box = driver.find_element_by_id('email')
usr_box.send_keys(usr)
pwd_box = driver.find_element_by_id('pass')
pwd_box.send_keys(pwd)
login_button = driver.find_element_by_id('loginbutton')
login_button.submit()
#<--- / code to login --->
#Wait until login
sleep(speed)
#<--- code to remove opaque screen --->
remover = driver.find_element_by_tag_name('body').click()
#<--- / code to remove opaque screen --->
#WALL
give = driver.find_element_by_xpath("//*[@name='xhpc_message']")
#Wait for wall
sleep(speed)
#DESCRIPTION
give.send_keys(desc)
sleep(speed)
#ATTACH MEDIA
file = driver.find_element_by_xpath("//input[@data-testid='media-sprout']")
sleep(speed)
#sending media
file.send_keys(path)
#wait while it uploads
sleep(speed*1.75)
#POST
post = driver.find_element_by_css_selector('button[data-testid="react-composer-post-button"]')
post.click()
#wait for post to be made
sleep(speed*1.5)
driver.close()
return
pass
app = Flask(__name__)
@app.route('/', methods = ['GET'])
def index():
return render_template('index.html')
@app.route('/', methods = ['POST'])
def go():
fun = request.form['fun']
fup = request.form['fup']
if fun is None or fup is None:
fun = fup = ""
file = request.files['media']
filename = secure_filename(file.filename)
media = os.path.abspath(filename)
file.save(media)
desc = request.form['desc']
speed = int(request.form['speed'])
Facebook(fun,fup,media,desc,speed)
return '''
<script>
alert('Success :)');
window.location = "/";
</script>
'''
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80,debug=False,threaded=True)