Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,8 +52,17 @@ setuptools.setup(
|
|
| 52 |
},
|
| 53 |
)
|
| 54 |
|
|
|
|
| 55 |
def main():
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
if st.button('Post to Facebook Groups'):
|
| 58 |
if not account or not password or not groups_links_list or not message or not images_list:
|
| 59 |
st.error("Please fill all the fields.")
|
|
@@ -66,6 +75,7 @@ def main():
|
|
| 66 |
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
|
| 67 |
driver.get('https://www.facebook.com')
|
| 68 |
|
|
|
|
| 69 |
emailelement = driver.find_element(By.XPATH,'//*[@id="email"]')
|
| 70 |
emailelement.send_keys(account)
|
| 71 |
passelement = driver.find_element(By.XPATH,'//*[@id="pass"]')
|
|
@@ -73,7 +83,8 @@ def main():
|
|
| 73 |
loginelement = driver.find_element(By.XPATH,'//*[@id="loginbutton"]')
|
| 74 |
loginelement.click()
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
for group in groups_links:
|
| 79 |
driver.get(group)
|
|
@@ -88,6 +99,16 @@ def main():
|
|
| 88 |
|
| 89 |
time.sleep(1)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
# Handle image uploads (assuming one upload field per image)
|
| 92 |
for image_file in images_list:
|
| 93 |
photo_element = driver.find_element(By.XPATH,'//input[@type="file"]')
|
|
|
|
| 52 |
},
|
| 53 |
)
|
| 54 |
|
| 55 |
+
|
| 56 |
def main():
|
| 57 |
+
# Input fields
|
| 58 |
+
st.title("Facebook Group Poster")
|
| 59 |
+
account = st.text_input("Facebook Account Email", "sample@gmail.com")
|
| 60 |
+
password = st.text_input("Facebook Password", "sample", type="password")
|
| 61 |
+
groups_links_list = st.text_area("Facebook Group URLs (one per line)",
|
| 62 |
+
"https://www.facebook.com/groups/sample1\nhttps://www.facebook.com/groups/sample2")
|
| 63 |
+
message = st.text_area("Post Message", "Checkout this amazing script...")
|
| 64 |
+
images_list = st.file_uploader("Upload Images", accept_multiple_files=True)
|
| 65 |
+
|
| 66 |
if st.button('Post to Facebook Groups'):
|
| 67 |
if not account or not password or not groups_links_list or not message or not images_list:
|
| 68 |
st.error("Please fill all the fields.")
|
|
|
|
| 75 |
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
|
| 76 |
driver.get('https://www.facebook.com')
|
| 77 |
|
| 78 |
+
# Login Logic (Replace XPaths if needed)
|
| 79 |
emailelement = driver.find_element(By.XPATH,'//*[@id="email"]')
|
| 80 |
emailelement.send_keys(account)
|
| 81 |
passelement = driver.find_element(By.XPATH,'//*[@id="pass"]')
|
|
|
|
| 83 |
loginelement = driver.find_element(By.XPATH,'//*[@id="loginbutton"]')
|
| 84 |
loginelement.click()
|
| 85 |
|
| 86 |
+
# Posting Logic
|
| 87 |
+
groups_links = groups_links_list.splitlines()
|
| 88 |
|
| 89 |
for group in groups_links:
|
| 90 |
driver.get(group)
|
|
|
|
| 99 |
|
| 100 |
time.sleep(1)
|
| 101 |
|
| 102 |
+
# Image Upload Logic (Adapt based on Streamlit setup)
|
| 103 |
+
for image_file in images_list:
|
| 104 |
+
photo_element = driver.find_element(By.XPATH,'//input[@type="file"]')
|
| 105 |
+
image_path = image_file.name # Placeholder! Adjust how you get the path
|
| 106 |
+
photo_element.send_keys(image_path)
|
| 107 |
+
time.sleep(1)
|
| 108 |
+
|
| 109 |
+
# time.sleep(6)
|
| 110 |
+
# post_button = driver.find_element_by_xpath("//*[@data-testid='react-composer-post-button']")
|
| 111 |
+
|
| 112 |
# Handle image uploads (assuming one upload field per image)
|
| 113 |
for image_file in images_list:
|
| 114 |
photo_element = driver.find_element(By.XPATH,'//input[@type="file"]')
|