eselejuanito / facebook-auto-post

This project is to do auto post in the marketplace of Facebook
40 stars 10 forks source link

Need a little bit of help: Small Error with the DB and another small one #3

Open mikhoul opened 3 weeks ago

mikhoul commented 3 weeks ago

First thanks for this software,

I have an error when I launch app.py with the SQlite DB: Failed to read data from sqlite table no such table: item I browsed the DB to see if there was such "table item" and there is no such "table item" inside.

But the python script that initialize the DB don't have an "item table" so I'm not sure what to do about it ? 🤔

image

But Selenium launch Chrome fine and log to my FB account fine too, but soon after app.python return another error and exit:

File "C:\facebook-auto-post-main\app.py", line 52, in __init__
    for post in self.posts:
TypeError: 'NoneType' object is not iterable

Could you help me to find why those 2 small errors happen ?

I'm not sure if those 2 errors are related since I'm really a novice with python. 🤔

Here's the complete output of the CMD line with Windows 10 and Chrome:

(env) C:\facebook-auto-post-main>python app.py

DevTools listening on ws://127.0.0.1:52854/devtools/browser/61b2b7a0-88cd-40e9-b7af-867ea92bc128
Failed to read data from sqlite table no such table: item
Traceback (most recent call last):
  File "C:\facebook-auto-post-main\app.py", line 224, in <module>
    app = App(facebook["email"], facebook["password"], configuration["language"], configuration["images_path"], configuration["time_to_sleep"], configuration["browser"])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\facebook-auto-post-main\app.py", line 52, in __init__
    for post in self.posts:
TypeError: 'NoneType' object is not iterable

(env) C:\facebook-auto-post-main>

Regards, :octocat:

eselejuanito commented 3 weeks ago

I have found the bug. You only need to rename your table from "post" to "item" or run again "create_database.py". Both bugs are going to be fixed.

mikhoul commented 3 weeks ago

Thanks, I will try it ! đź‘Ť

mikhoul commented 3 weeks ago

@eselejuanito Just to let you know I've made a small change to the login section since I had hardtime with the button on the login page so instead of finding the button with the xpath to click on I've implanted a more robust way that is just to simulate a keypress on the ENTER key on the keyboard instead of parsing the HTML with the Xpath to click on the button.

This way even if the CSS-HTML change on the login page, pressing Enter will always work.

password_input = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "pass")))
            password_input.send_keys(self.password)
            logging.info("Password input found and filled")

            # Simuler la touche "Entrée" après avoir entré le mot de passe
            password_input.send_keys(Keys.ENTER)
            logging.info("Simulated Enter key press")

Regards :octocat: