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

  • 相关阅读:
    编译原理第一次作业
    【码制】关于原码,反码,补码的一些笔记和理解
    输出1到50以内的所有素数【C】
    方法和数组
    if条件判断和switch,for do while
    变量
    全选,删除,添加
    java基础
    二级联
    轮播图
  • 原文地址:https://www.cnblogs.com/aifengguo/p/11239722.html
Copyright © 2011-2022 走看看