<span style="font-size:18px;"># -*- coding: utf-8 -*-
"""
Created on Sun Oct 23 16:16:58 2016
@author: alis
模拟知乎登陆
"""
from selenium import webdriver
import time
browser = webdriver.Firefox()
browser.get('http://www.zhihu.com/#signin')
browser.find_element_by_name("account").clear()
browser.find_element_by_name("password").clear()
browser.find_element_by_name("account").send_keys("input your account")
browser.find_element_by_name("password").send_keys("input your password")
time.sleep(7) # 给时间手动输入验证码
browser.find_element_by_xpath("/html/body/div/div/div[2]/div[2]/form/div[2]/button").click()
time.sleep(7) # 登陆需要时间
"""-----------------------
do something
-----------------------"""
browser.close() #退出登陆</span>
python之selenium模拟登录知乎
最新推荐文章于 2024-06-23 18:11:47 发布