[python]抓取股票交易记录
来源:互联网 发布:数据库编程技术期末 编辑:程序博客网 时间:2024/05/03 18:17
#!/usr/bin/python#DownByDate.py sh600115 2014-12-29 2015-3-15#DownByDate.py stock_num start_date end_date#http://stock.gtimg.cn/data/index.php?appn=detail&action=download&c=sh600115&d=20141229#sh600115_2014-12-29.txtimport sysimport urllibimport datetimedef download_date(src_url,dest_file):download=urllib.FancyURLopener();download_page=download.open(src_url);savefile=file(dest_file,'wb+');while True:arr = download_page.read();if len(arr)==0:break;savefile.write(arr);savefile.flush();savefile.close();returnstock_code=sys.argv[1]str_0='''http://stock.gtimg.cn/data/index.php?appn=detail&action=download&c='''str_0=str_0 + stock_code + '&d='date_start=datetime.datetime.strptime(sys.argv[2],'%Y-%m-%d')if len(sys.argv)>3:date_end=datetime.datetime.strptime(sys.argv[3],'%Y-%m-%d')else:date_end=date_start+datetime.timedelta(days=1)while date_start<date_end:str_date=date_start.strftime('%Y%02m%02d')str_url=str_0+str_datestr_file=stock_code + '_' + date_start.strftime('%Y-%02m-%02d') + '.txt'download_date(str_url,str_file)print str_filedate_start=date_start+datetime.timedelta(days=1)
0 0
- [python]抓取股票交易记录
- 2017.9.9 股票交易 思考记录
- 使用golang从雅虎抓取股票交易数据
- python抓取历年特码开奖记录
- python抓取历年特码开奖记录
- python抓取历年特码开奖记录
- python抓取历年特码开奖记录
- 股票交易
- Python抓取天猫商品详细信息及交易记录
- python 股票交易数据按名称 开户时间 结束时间入库
- mysql随机抓取记录
- python 抓取 外汇牌价
- 使用python抓取网页
- Python抓取中文网页
- python抓取网页图片
- Python抓取中文网页
- Python抓取中文网页
- python 抓取网页代码
- 网络编程(原始套接字)
- 走向大神之springMVC(二)
- Qt基础技术(经验积累)
- C++、Java、JavaScript中迭代器的用法
- HDU 4135 Co-prime(组合+容斥)
- [python]抓取股票交易记录
- NYOJ 字串和之差 (dp)
- GET和POST区别详解
- 宏定义变参printf
- T_SQL聚合函数使用方法
- Android—ActivityGroup管理Activity,带ListView(转载)
- Structs vs classes(值类型vs引用类型)
- 学习笔记之灵活运用数组下标
- [Java学习]阶乘求法