Search code examples
pythonfacebookpython-3.xclipboardstatus

Updating facebook status with Python3 using browser


i've been testing ways of updating facebook status with python, i managed to do it with urllib module but now im trying to do the same but by opening facebook in a browser and pasting my status that is stored in a clipboard. What i need is a script that chooses the status form on facebook. Mechanize seems like a module that would fix my problem, but it dosen't support Python3

import tkinter
import win32
import win32com
from win32com import client
import time
import webbrowser

r = tkinter.Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append('my status')
r.destroy()

shell = client.Dispatch("Wscript.Shell")
webbrowser.open('https://www.facebook.com/?ref=tn_tnmn')
time.sleep(10)
shell.SendKeys('^{V}')

Solution

  • Instead of doing it with COM+ (which is windows-dependent, hard to manipulate browser), you can use selenium.

    It supports many browsers. And you can use css selector, xpath.