asperduti / creator-studio-cli

Tool for automated interactions on Creator Studio, like upload to Instagram or Facebook.
MIT License
19 stars 2 forks source link

not login to facebook, immediately click instagram button #5

Closed sakarimov closed 4 years ago

sakarimov commented 4 years ago

i guess it's because the app failed to catch facebook login button in the first place, then directly catch instagram button

this is what i get in my terminal

User is logged Timeout Exception in explicit wait Traceback (most recent call last): File "./from_csv.py", line 15, in cs_cli.create_post(account=post[0], File "/home/cikapc/creator-studio-cli/creator_studio/creator_studio.py", line 31, in create_post instagram.create_post(self.browser, account, message, file, schedule_options=schedule_options) File "/home/cikapc/creator-studio-cli/creator_studio/instagram.py", line 33, in create_post create_post_button = browser.find_element_by_xpath(xpath["instagram"][create_post.name]["create_post_button"]) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //div[text()='Create Post']

2020-09-04_09-25

asperduti commented 4 years ago

Hi @sakarimov I will help you with this. I know that the documentation is missing, but let's fix it.

In order to use this tool, you need to set up two things:

Now let's go to code. You have to create a python file, in the examples, you have a file that you can use. In this file, you have to create a CreatorStudio object, and you have to pass to it the way you want to login. You have two options to login(choose one).

Log in with Email and password

cs_cli = CreatorStudio("YOUR_EMAIL", "YOUR_PASSWORD")
cs_cli.login()

Enter with a Firefox session with a Facebook account already logged.

cs_cli = CreatorStudio("YOUR_EMAIL", "YOUR_PASSWORD", browser_profile_path="/home/arielsperduti/.mozilla/firefox/5gs2k9uib.default-release/")
cs_cli.login()

Here you have to set up correctly browser_profile_path with the value where is stored you Firefox session.

And to start posting, just:

cs_cli.create_post(account=<Your instagram account/facebook page>,
                              message=<message>,
                              file=<Full path to a photo>,
                              schedule_options={
                                 "date": <MM/DD/YYYY>,
                                 "time": <H:MM A/P>
                              },
                              social_network="instagram")

Also, I made a small update to the code, because there was a change with the interface. Update it before to try all this. And tell me what's happen.

sakarimov commented 4 years ago

thanks..., let me try it, i'll post what i get

sakarimov commented 4 years ago

i logged in my account and defined browser_profile_path i still get this error

Traceback (most recent call last): File "from_csv.py", line 9, in cs_cli.login() File "/home/cikapc/creator-studio-cli/creator_studio/creator_studio.py", line 18, in login if is_user_loged(self.browser): File "/home/cikapc/creator-studio-cli/creator_studio/login_util.py", line 41, in is_user_loged button = browser.find_elements_by_xpath(xpath[is_user_loged.name]["login_button"]) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 410, in find_elements_by_xpath return self.find_elements(by=By.XPATH, value=xpath) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1005, in find_elements return self.execute(Command.FIND_ELEMENTS, { File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/cikapc/creator-studio-cli/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "//div[text()='Facebook Login'" is invalid: SyntaxError: The expression is not a legal expression.

asperduti commented 4 years ago

Yes, I made a mistake, things that happen when you try to code fast and don't test... Now it should be fixed. I hope are no more mistakes xD.

Please, update your repo and tell me how it is going.

sakarimov commented 4 years ago

i'm sorry my bad, i also don't read the error, it says invalid: SyntaxError, i just changed it and it is loged now

asperduti commented 4 years ago

Close on #4