zoukankan      html  css  js  c++  java
  • python使用chrom登陆微博

    # -*- coding:utf-8 -*-

    import json
    import requests
    from selenium import webdriver
    import time

    class 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'])

  • 相关阅读:
    Linux分区
    Vim 基本配置
    Ubuntu几种常见乱码解决方法
    ADB
    ubuntu下安装配置ADB
    Tinyos学习笔记(三)
    Tinyos学习笔记(二)
    Codeforces Round #249 (Div. 2) A题
    poj 2007 Scrambled Polygon(极角排序)
    MemSQL Start[c]UP 2.0
  • 原文地址:https://www.cnblogs.com/aifengguo/p/11239722.html
Copyright © 2011-2022 走看看