# -*- coding:utf-8 -*-import jsonimport requestsfrom selenium import webdriverimport timeclass WeiboAuthorize(object): loginUrl = 'https://passport.weibo.cn/signin/login' chromePath = './chromedriver.exe' def __init__(self): pass def getweibouser(self): return {'username': '你的微博用户名','password': '你的微博密码'}
def loginWeibo(self, username, password): self.driver = webdriver.Chrome(self.chromePath) self.driver.get(self.loginUrl) time.sleep(1) self.driver.find_element_by_id("loginName").send_keys(username) self.driver.find_element_by_id("loginPassword").send_keys(password) time.sleep(1) self.driver.find_element_by_id("loginAction").click() time.sleep(3) self.driver.get(self.authorizeUrl) time.sleep(3) self.driver.close()if __name__ == '__main__': c = WeiboAuthorize() params = c.getweibouser() if params['username'] and params['password'] : c.loginWeibo(params['username'], params['password'])
转载于:https://www.cnblogs.com/aifengguo/p/11239722.html
相关资源:python3实现读取chrome浏览器cookie