自动登录开源中国 发表弹一弹

#coding:utf-8
from os import environ
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

chromedriver = "C:\chromedriver\chromedriver.exe"
environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.maximize_window()
driver.get("https://www.oschina.net/home/login?goto_page=https%3A%2F%2Fwww.oschina.net%2F")

# 点登录按钮,输入账号密码后登录
driver.find_element_by_id('userMail').send_keys("用户名")
driver.find_element_by_id('userPassword').send_keys("密码")
driver.find_element_by_xpath('//*[@id="account_login"]/form/div/div[5]/button').click()
driver.implicitly_wait(100)

print driver.title
now_url = driver.current_url
driver.get(now_url)
print now_url
driver.find_element_by_class_name("tweet-editor").clear()
driver.find_element_by_class_name("tweet-editor").send_keys(u"机器人弹一弹3")
driver.find_element_by_xpath('//*[@id="tweet"]/div/div/button').click()
now_url = driver.current_url
driver.get(now_url)
print now_url

转载于:https://my.oschina.net/qianyenum/blog/1489745

你可能感兴趣的:(自动登录开源中国 发表弹一弹)