This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post_image.resizeImage(social_media_account=social_media_account) | |
| social_media_platform = SocialMedia(social_media_account=social_media_account) | |
| social_media_platform.setSocialMediaClass() | |
| social_media_platform.composeSocialMediaContent(image_filename=post_image.image_filename, post_details=gsheet.post_details) | |
| social_media_platform.postSocialMediaContent() | |
| social_media_platform.addLocationSocialMediaContent() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sleep(1) | |
| pyautogui.press('tab') | |
| save_button = self.browser.find_element_by_id('inlineEditorSave') | |
| save_button.click() | |
| print('Location successfully added to post.') | |
| print('Closing browser.') | |
| self.browser.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while True: | |
| try: | |
| pyautogui.click('/home/machine/projects/social-media-marketing-bot/src/PyAutoGUI/photo_location.png') | |
| sleep(2) | |
| pyautogui.typewrite(self.post_location, interval=0.1) | |
| break | |
| except: | |
| print('Not found') | |
| continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while True: | |
| try: | |
| pyautogui.click('/home/machine/projects/social-media-marketing-bot/src/PyAutoGUI/add_location_button.png') | |
| sleep(2) | |
| break | |
| except: | |
| print('Not found') | |
| continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pyautogui.click('/home/machine/projects/social-media-marketing-bot/src/PyAutoGUI/browser_sizes.png') | |
| sleep(2) | |
| pyautogui.click('/home/machine/projects/social-media-marketing-bot/src/PyAutoGUI/block_notification_button.png') | |
| sleep(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Wait for post to load | |
| while True: | |
| try: | |
| browser_sizes = pyautogui.locateOnScreen('/home/machine/projects/social-media-marketing-bot/src/PyAutoGUI/browser_sizes.png') | |
| print('Post has loaded') | |
| sleep(2) | |
| break | |
| except: | |
| continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Wait for dashboard page to load | |
| while True: | |
| try: | |
| dashboard_menu_item = self.browser.find_element_by_class_name('_1vp5') | |
| print('Successfully logged in to Facebook.') | |
| sleep(2) | |
| break | |
| except NoSuchElementException: | |
| continue | |
| facebook_post_url = f'{FACEBOOK_POST_BASE_URL}{self.fb_post_id}/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Type the username | |
| for username_char in self.FACEBOOK_USERNAME: | |
| username_field.send_keys(username_char) | |
| sleep(0.1) | |
| # Type the password | |
| for password_char in self.FACEBOOK_PASSWORD: | |
| password_field.send_keys(password_char) | |
| sleep(0.1) | |
| # Click on the log in button | |
| log_in_button = self.browser.find_element_by_name('login').click() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Wait for the element: | |
| while True: | |
| try: | |
| username_field = self.browser.find_element_by_name('email') | |
| password_field = self.browser.find_element_by_name('pass') | |
| break | |
| except NoSuchElementException: | |
| continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def addPostLocation(self): | |
| """Adds a location to the Facebook post.""" | |
| options = webdriver.ChromeOptions() | |
| options.add_argument('disable-infobars') | |
| self.chrome_path = r'/usr/bin/chromedriver' | |
| self.browser = webdriver.Chrome(self.chrome_path, options=options) | |
| self.FACEBOOK_USERNAME = FACEBOOK_USERNAME | |
| self.FACEBOOK_PASSWORD = FACEBOOK_PASSWORD | |
| # Get the Facebook login page |
NewerOlder