Created
June 20, 2020 14:19
-
-
Save south1907/f97b957907fae4fc3d9fae3dc9d71930 to your computer and use it in GitHub Desktop.
Login facebook messenger and chat
This file contains 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
from selenium.webdriver import Chrome, ChromeOptions | |
from selenium.webdriver.common.keys import Keys | |
import time | |
email = '[email protected]' | |
password = 'yourpassword' | |
browser = Chrome() | |
url = 'https://www.facebook.com/' | |
browser.get(url) | |
# nhập username, password | |
email_input = browser.find_element_by_xpath('//input[@type="email"]') | |
email_input.send_keys(email) | |
pass_input = browser.find_element_by_xpath('//input[@type="password"]') | |
pass_input.send_keys(password) | |
pass_input.send_keys(Keys.RETURN) | |
url_mes = 'https://messenger.com/' | |
browser.get(url_mes) | |
time.sleep(5) | |
# click vào nút cho phép đăng nhập với account facebook hiện tại | |
submit_input = browser.find_element_by_xpath('//button[@type="submit"]') | |
submit_input.click() | |
url_mes_account_1 = 'https://www.messenger.com/t/100037068474173' | |
browser.get(url_mes_account_1) | |
# chat tin nhắn | |
text = 'hi' | |
text_input = browser.find_element_by_xpath('//div[@role="combobox"]') | |
text_input.send_keys(text) | |
text_input.send_keys(Keys.RETURN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment