利用selenium登陆智联招聘,获取cookie
2016-06-08 15:33
766 查看
# -*- coding: utf-8 -*- import time import requests from pandas import Series, DataFrame import sys reload(sys) from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC sys.setdefaultencoding("utf-8") from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver import ActionChains driver = webdriver.PhantomJS() #driver.set_page_load_timeout(20)#防止页面加载个没完 driver.get("http://my.zhaopin.com/jobseeker/loginmgr/marketing-resume20120510.html?utm_source=other&utm_medium=cnt&utm_term=&utm_campaign=121122523&utm_provider=zp&sid=121122523&site=u2757491.k18203734528.a2680930731.pb") driver.find_element_by_xpath('//li[@class="li2"]').click() time.sleep(3) driver.find_element_by_xpath('//input[@name="loginname"]').send_keys('*****')#你的用户名 driver.find_element_by_xpath('//input[@name="password"]').send_keys('*****')#你的密码 time.sleep(2) driver.get_screenshot_as_file('show1.png') driver.find_element_by_xpath('//input[@name="loginbutton"]').click() try: dr = WebDriverWait(driver, 60) dr.until(lambda the_driver:the_driver.find_element_by_xpath('//div[@class="myResume"]').is_displayed()) except Exception,e: print("登陆失败!") finally: t=driver.title if t==u'简历中心': print u"登录成功" driver.get_screenshot_as_file('show2.png') #遍历cookies中的name 和value信息打印, cookie = [item["name"] + "=" + item["value"] for item in driver.get_cookies()] cookiestr = ';'.join(item for item in cookie) print cookiestr
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- install scrapy with pip and easy_install
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中