以下是用python简单的自动化登录知乎的python代码

#coding:utf-8

import os,time

from os import environ

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.action_chains import ActionChains

chromedriver = "C:\chromedriver\chromedriver.exe"

environ["webdriver.chrome.driver"] = chromedriver

driver = webdriver.Chrome(chromedriver)

driver.maximize_window()

driver.get("https://www.zhihu.com/#signin")

driver.find_element_by_xpath('//*[@class="account input-wrapper"]/input').send_keys("用户名")

driver.find_element_by_xpath('//*[@class="verification input-wrapper"]/input').send_keys("密码")

time.sleep(2)

#鼠标点击,刷新验证码

#driver.find_element_by_class_name("Captcha-refresh js-refreshCaptcha sprite-index-icon-refresh").click()

for i in range(0,100) :

try:

driver.find_element_by_xpath('//*[@class="Captcha-imageConatiner"]/img').is_displayed()

except:

print "未找到元素,自动登录成功"

break

else:

right_click=driver.find_element_by_xpath('//*[@class="Captcha-imageConatiner"]/img')

#移动到距某个元素(左上角坐标)多少距离的位置

ActionChains(driver).move_to_element_with_offset(right_click,160,22).click().perform()

driver.find_element_by_xpath('//*[@class="button-wrapper command"]/button').click()

time.sleep(3)

print 'login OK !!!'

print '##########提交问题#####'

driver.find_element_by_class_name("TopstoryHeader-navItem").click()

now_url = driver.current_url

print now_url

time.sleep(10)

try:

driver.find_element_by_xpath('//*[@class="Input-wrapper Input-wrapper--spread Input-wrapper--multiline Input-wrapper--large"]/textarea').is_displayed()

except:

print "未找到元素"

else:

driver.find_element_by_xpath('//*[@class="Input-wrapper Input-wrapper--spread Input-wrapper--multiline Input-wrapper--large"]/textarea').send_keys(u"python机器人自动测试问题?")

#driver.find_element_by_xpath('//*[@class="QuestionAsk-buttonGroup"]/button').click()

#driver.find_element_by_xpath('//*[@class="Input-wrapper Input-wrapper--spread Input-wrapper--large"]/input').send_keys(u"pyton自动化")

#driver.find_elements_by_class_name("public-DraftStyleDefault-block public-DraftStyleDefault-ltr").send_keys(u"如何用python脚本破解知乎登录验证码")

#driver.find_element_by_xpath('//*[@class="QuestionAsk-buttonGroup"]/button').click()

print '##########提交问题OK#####'

#

python 知乎登录_python自动化登录知乎相关推荐

  1. python网站自动答题_python自动登录网站答题-女性时尚流行美容健康娱乐mv-ida网...

    女性时尚流行美容健康娱乐mv-ida网 mvida时尚娱乐网 首页 美容 护肤 化妆技巧 发型 服饰 健康 情感 美体 美食 娱乐 明星八卦 首页  > 高级搜索 cookie实现 自动 登录 ...

  2. python自动办公知识点_Python自动化办公知识点整理汇总|简明python教程|python入门|python教程...

    https://www.xin3721.com/eschool/pythonxin3721/ 知乎上有人提问:用python进行办公自动化都需要学习什么知识呢? ​ 这可能是很多非IT职场人士面临的困 ...

  3. python爬取知乎话题_python爬取知乎话题图片

    前言 什么是网络爬虫(也叫网络蜘蛛)?简单来说,是一种用来自动浏览万维网程序或脚本(网络爬虫的典型应用就是我们所熟知的搜索引擎).既然如此,那么我们也可以写一个程序,用来自动浏览或者获取网页上的信息. ...

  4. python多用户登录_python 多用户登录

    原博文 2017-09-07 15:18 − Python多用户登录 需求 让用户输入用户名密码 认证成功后显示欢迎信息 输错三次后退出程序 可以支持多个用户登录 (提示,通过列表存多个账户信息) 用 ...

  5. python实现远程登录_python远程登录代码

    在 python 中有一个 telnetlib,它的作用就是建立一个通到主机的 telnet连线实体, 然后向主机传送命令 (就像用键盘输入一样 )并从该连线接收数据.利用它, 我们可以把示范 1的所 ...

  6. python.123登录_python用户登录3次

    需求说明: 用户登录,对密码进行三次校验,三次均失败后,将锁定用户名,不允许登录. 解决方案: 1.明确可成功登录的用户名和密码: 2.用户黑名单,三次登录失败后,将用户名写入黑名单: 3.检测黑名单 ...

  7. python用户登录_python用户登录系统

    本文实例为大家分享了用户登录系统python实现代码,供大家参考,具体内容如下 注意事项: 1.使用python3执行程序.按提示输入1或2,登录或退出程序 2.输入用户名后,如果用户名被锁定及无效用 ...

  8. python画矩阵图_Python根据已知邻接矩阵绘制无向图操作示例

    本文实例讲述了Python根据已知邻接矩阵绘制无向图操作.分享给大家供大家参考,具体如下: 有六个点:[0,1,2,3,4,5,6],六个点之间的邻接矩阵如表格所示,根据邻接矩阵绘制出相对应的图 0 ...

  9. python爬虫知乎图片_python 爬取知乎图片

    先上完整代码 1 importrequests2 importtime3 importdatetime4 importos5 importjson6 importuuid7 from pyquery ...

最新文章

  1. 远哥教你MuleESB系列视频教程
  2. Python reduce 函数 - Python零基础入门教程
  3. java怎么接收前端请求_前端json post 请求 后端怎么接收
  4. 【C/C++】运算符优先级记忆
  5. isset、is_null、empty的区别
  6. BigPipe为什么可以节省时间?
  7. 知乎每日精选python阅读脚本
  8. 4参数逻辑曲线公式及其含义
  9. 简单就是美,桌面管理Fences分享
  10. 基因组测序 转录组测序
  11. 联想笔记本 插电源 拔电源 黑屏问题解决。
  12. L1-064 估值一亿的AI核心代码 (20 分)
  13. 工具优化篇之IDEA新UI+日常插件
  14. 蓝底证件照rgb值是多少?一个方法帮你搞定
  15. iOS 百度地图之坐标转换
  16. 树莓派呼吸灯python代码
  17. Schema Compare 使用手册
  18. 值得程序员和设计师关注的微信公众号
  19. 51单片机-4-数码管的显示
  20. 【德勤报告:区块链变革媒体业有五种可能】

热门文章

  1. 阿里中台(看图不说话)
  2. Python、JavaScript、Go、Linux学习资料总结
  3. 获取族的实例参数和类型参数
  4. new Set 去重和其他方法
  5. 【嵌入式知识12】使用PWM实现LED呼吸灯
  6. Struts2.xml结构
  7. [Stanford Algorithms: Design and Analysis, Part 2] c27 The Knapsack Problem
  8. 人工智能时代:为什么孩子们应该学习编程?人人会编程、少儿编程、程序员年龄越来越年轻化了……
  9. 对固态硬盘ssd进行4k对齐
  10. 使用SAX和XSLT实现复杂数据转换(组图)