from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time from time import sleep from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import streamlit as st import setuptools with open("README.md", encoding="utf-8") as readme_file: readme = readme_file.read() setuptools.setup( name='webdriver_manager', python_requires=">=3.7", long_description=readme, long_description_content_type="text/markdown", packages=setuptools.find_packages(include=['webdriver_manager*']), include_package_data=True, version='4.0.1', description='Library provides the way to automatically manage drivers for different browsers', author='Sergey Pirogov', author_email='automationremarks@gmail.com', url='https://github.com/SergeyPirogov/webdriver_manager', keywords=['testing', 'selenium', 'driver', 'test automation'], classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Information Technology', 'Intended Audience :: Developers', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Topic :: Software Development :: ' 'Libraries :: Python Modules', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: Unix', 'Operating System :: MacOS', ], install_requires=[ 'requests', 'python-dotenv', 'packaging' ], package_data={ "webdriver_manager": ["py.typed"] }, ) def main(): # Input fields st.title("Facebook Group Poster") account = st.text_input("Facebook Account Email", "sample@gmail.com") password = st.text_input("Facebook Password", "sample", type="password") groups_links_list = st.text_area("Facebook Group URLs (one per line)", "https://www.facebook.com/groups/sample1\nhttps://www.facebook.com/groups/sample2") message = st.text_area("Post Message", "Checkout this amazing script...") images_list = st.file_uploader("Upload Images", accept_multiple_files=True) if st.button('Post to Facebook Groups'): if not account or not password or not groups_links_list or not message or not images_list: st.error("Please fill all the fields.") else: chrome_options = Options() prefs = {"profile.default_content_setting_values.notifications": 2} chrome_options.add_experimental_option("prefs", prefs) with st.spinner("Posting to Facebook..."): driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options) driver.get('https://www.facebook.com') # Login Logic (Replace XPaths if needed) emailelement = driver.find_element(By.XPATH,'//*[@id="email"]') emailelement.send_keys(account) passelement = driver.find_element(By.XPATH,'//*[@id="pass"]') passelement.send_keys(password) loginelement = driver.find_element(By.XPATH,'//*[@id="loginbutton"]') loginelement.click() # Posting Logic groups_links = groups_links_list.splitlines() for group in groups_links: driver.get(group) time.sleep(2) try: driver.find_element(By.XPATH,'//*[@label="Start Discussion"]').click() post_box=driver.find_element_by_css_selector("[name='xhpc_message_text']") except: post_box=driver.find_element_by_css_selector("[name='xhpc_message_text']") post_box.send_keys(message) time.sleep(1) # Image Upload Logic (Adapt based on Streamlit setup) for image_file in images_list: photo_element = driver.find_element(By.XPATH,'//input[@type="file"]') image_path = image_file.name # Placeholder! Adjust how you get the path photo_element.send_keys(image_path) time.sleep(1) # time.sleep(6) # post_button = driver.find_element_by_xpath("//*[@data-testid='react-composer-post-button']") # Handle image uploads (assuming one upload field per image) for image_file in images_list: photo_element = driver.find_element(By.XPATH,'//input[@type="file"]') photo_element.send_keys(image_file.name) # Or image_file.path, adjust as needed time.sleep(1) time.sleep(6) post_button = driver.find_element_by_xpath("//*[@data-testid='react-composer-post-button']") # ... (Rest of your logic to click the post button) driver.close() if __name__ == '__main__': main()