python模拟登陆“春秋航空”官网+手动输入验证码
2017-11-25 18:06
411 查看
# coding:utf8 import requests #识别验证码转换数据 def captcha(captcha_data): with open("chunqiu.jpg","wb") as f: f.write(captcha_data) text=raw_input("输入验证码:") return text def chunqiuLogin(): # 构建一个session对象,可以保存cookie sess=requests.Session() headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36", "Connection": "keep-alive"} # html = sess.get("https://account.flycua.com/sso/index.htm?returnUrl=http://www.flycua.com/member/member-login!loginJump.shtml", headers=headers).text # 验证码url固定不变 image_url ="https://account.flycua.com/sso/chineseVerifyCode.images" #发送图片的请求获取图片数据流 captcha_data=sess.get(image_url,headers=headers).content #获取验证码里的文字,需要手动输入 text=captcha(captcha_data)
#保护个人隐私,账号密码是虚构的,需要填写真实的data={ "loginUser":"1111111111", "password":"8116189", "verifyCode":text, } #先post相关登陆需要的参数,模拟登陆 response=sess.post("https://account.flycua.com/sso/login.htm",data=data,headers=headers) #输出是否登陆成功 print response.text # 获取陶然的个人主页 response=sess.get("https://m.flycua.com/h5/user/index.html",headers=headers) print response.text # 将爬取的主页转换HTML,生成my.html文件 # with open("my.html","w") as f: # f.write(response.text.encode("utf-8"))if __name__ == "__main__": chunqiuLogin()
相关文章推荐
- python模拟浏览器登陆淘宝(设置代理、输入验证码)
- PHP的curl带验证码模拟登陆学校的教务系统(验证码已被自动识别,不需要输入)
- python---pexpect的ssh模拟ssh登陆,针对个别主机命令输入
- Python模拟登陆3: 进入选课系统(手工输入验证码阶段)
- python 淘宝系列(二):处理验证码的模拟登陆
- python-51: 带有验证码的模拟登陆
- python urllib2 cookielib处理验证码模拟人人登陆
- 【Python】【验证码识别】python 模拟登陆时,验证码自动识别问题
- python 模拟登陆联合航空 处理验证码
- 当模拟登陆遇到验证码
- 利用Python requests库模拟登陆学校教务系统
- 微博模拟登陆之验证码的解决方法
- Python模拟登陆实现代码
- python模拟网站登陆
- 手动输入验证码
- python模拟登录有验证码的网站记录
- python爬虫之模拟登陆csdn
- 第三百四十三节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy模拟登陆和知乎倒立文字验证码识别
- Python模拟百度自动输入搜索功能
- [置顶] 【python 爬虫】linux 下 selenium+phantomjs 自动模拟登陆