爬取12306验证码图片
来源:互联网 发布:宝宝模样合成软件 编辑:程序博客网 时间:2024/05/26 09:56
# -*- coding:utf-8 -*-import timeimport urllib2import ssl def get_code_picture(local_filename): #目的为了通过未认证的12306证书 ssl._create_default_https_context = ssl._create_unverified_context req = urllib2.Request("https://kyfw.12306.cn/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand&0.6551712691897946") req.add_header("Referer","https://kyfw.12306.cn/otn/login/init") req.add_header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36") codeimg = urllib2.urlopen(req).read() with open(local_filename, 'wb') as f: f.write(codeimg)if __name__ == "__main__": for i in xrange(0x7fffffff): path = './123062/' + str(i+1) +'.jpg' get_code_picture(path) print path #由于12306过快刷新会提示稍后再来,所以再此休眠一秒。 time.sleep(1)
阅读全文
0 0
- 爬取12306验证码图片
- python 爬取12306验证码
- C# 取WebBrowser中图片 可用于获取验证码
- C#取验证码
- Python爬取图片
- Python爬取图片
- 爬取网页图片
- Python3爬取图片
- Scrapy爬取图片
- 简单爬取图片
- python爬取图片
- 爬取美女图片
- 爬取图片
- 爬取网站图片
- scrapy爬取图片
- 爬取网页图片
- python爬取图片
- xpath 爬取图片
- vimの的两合字母
- greenDao3.x 深入使用
- 慢日志查询 MySQLdumpslow 命令用法详解
- 自定义控件出现Custom view * is not using the 2- or 3-argument View constructors
- 深入学习javascript--Module模式
- 爬取12306验证码图片
- 转发与重定向的区别
- 基于原始套接字(raw socket)的网络抓包工具
- JAVA编程思想学习 --- 第一章 (对象入门)
- Predix UI组件本地化
- Invalid byte tag in constant pool: 15报错解决
- DL/T645规约解析
- 通过 intent安装 apk
- Dreamweaver使用妙招:打开不支持的后缀并可识别