Browse Source

Add option for headless mode

update README with instructions on chromedriver

Minor refactor and reformatting

- Tighten whitespace
- Remove superfluous `assert` statement

Minor refactoring and reformatting

Fix missing whitespace between =

Update deletefb.py

Remove git stuff
pull/10/head
ConnorSkees 6 years ago
parent
commit
5367f424f0
  1. 4
      README.md
  2. 78
      deletefb/deletefb.py

4
README.md

@ -19,8 +19,8 @@ Personally, I did this so I would feel less attached to my Facebook profile
## How To Use ## How To Use
* Make sure that you have Google Chrome installed and that it is up to date, as * Make sure that you have Google Chrome installed and that it is up to date
well as the chromedriver for Selenium. See [here](https://sites.google.com/a/chromium.org/chromedriver/downloads). On Arch Linux you can find this in the `chromium` package, but it will vary by OS. * Also install the chromedriver for Selenium. See [here](https://sites.google.com/a/chromium.org/chromedriver/downloads). On Arch Linux you can find this in the `chromium` package, and on Ubuntu it is `chromium-chromedriver`.
* `pip3 install --user delete-facebook-posts` * `pip3 install --user delete-facebook-posts`
* `deletefb -E "youremail@example.org" -P "yourfacebookpassword" -U "https://www.facebook.com/your.profile.url"` * `deletefb -E "youremail@example.org" -P "yourfacebookpassword" -U "https://www.facebook.com/your.profile.url"`
* The script will log into your Facebook account, go to your profile page, and * The script will log into your Facebook account, go to your profile page, and

78
deletefb/deletefb.py

@ -10,32 +10,55 @@ MAX_POSTS = 5000
def run_delete(): def run_delete():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-E", parser.add_argument(
"--email", "-E",
default=None, "--email",
help="Your email address associated with the account") required=True,
dest="email",
parser.add_argument("-P", type=str,
"--password", help="Your email address associated with the account"
default=None, )
help="Your Facebook password")
parser.add_argument(
parser.add_argument("-U", "-P",
"--profile-url", "--password",
default=None, required=True,
help=""" dest="password",
The link to your Facebook profile, e.g. https://www.facebook.com/your.name type=str,
""") help="Your Facebook password"
)
parser.add_argument(
"-U",
"--profile-url",
required=True,
dest="profile_url",
type=str,
help="The link to your Facebook profile, e.g. https://www.facebook.com/your.name"
)
parser.add_argument(
"-H",
"--headless",
action="store_true",
dest="is_headless",
default=False,
help="Run browser in headless mode (no gui)"
)
args = parser.parse_args() args = parser.parse_args()
delete_posts(user_email_address=args.email, delete_posts(
user_password=args.password, user_email_address=args.email,
user_profile_url=args.profile_url) user_password=args.password,
user_profile_url=args.profile_url,
def delete_posts(user_email_address=None, is_headless=args.is_headless
user_password=None, )
user_profile_url=None):
def delete_posts(user_email_address,
user_password,
user_profile_url,
is_headless):
""" """
user_email_address: Your Email user_email_address: Your Email
user_password: Your password user_password: Your password
@ -50,10 +73,15 @@ def delete_posts(user_email_address=None,
chrome_options = Options() chrome_options = Options()
prefs = {"profile.default_content_setting_values.notifications" : 2} prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs", prefs) chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("start-maximized") chrome_options.add_argument("start-maximized")
driver = Chrome(chrome_options=chrome_options) if is_headless:
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('log-level=2')
driver = Chrome(options=chrome_options)
driver.implicitly_wait(10) driver.implicitly_wait(10)
driver.get("https://facebook.com") driver.get("https://facebook.com")

Loading…
Cancel
Save