1 Star 0 Fork 0

李贞/stock_selection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
baidu_index.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
yan.haifeng 提交于 2015-07-16 14:27 . init stock selection
__author__ = 'evan'
import datetime
import httplib2
import json
STOCK_TYPE = {'hotest' : 274, 'small' : 277, 'startup' : 276}
def baidu_index(stock_type):
date = datetime.date.today()
print date
url = "http://top.baidu.com/clip?line=20&b=" + str(STOCK_TYPE[stock_type])
http_client = httplib2.Http('.cache')
resp, content = http_client.request(url, "GET")
rise_list = []
for i in content.split('\n'):
if 'BD_DATA' in i:
data = i.split('BD_DATA=')[1][:-2]
res_list = json.loads(data)
print '\n== %s most rise in first 5=='%stock_type
for i in res_list[:5]:
if i.get('trend') == 'rise':
print i['title'], i['clicks']
print '\n==most 5=='
for i in res_list[:5]:
print i['title'], i['clicks']
print '\n==most rise =='
for i in res_list:
if i.get('trend') == 'rise':
del i['tit_url']
del i['detail_url']
rise_list.append(i)
print i['title'], i['clicks']
print '\n============================\n'
break
# date = datetime.date.today()
# with open(str(date) + "_baidu_hot_search.txt","w") as fb:
# fb.writelines(json.dumps(rise_list, encoding='gbk'))
if __name__ == '__main__':
stock_types=['hotest', 'small', 'startup']
for i in stock_types:
baidu_index(i)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lizhen_hbu/stock_selection.git
git@gitee.com:lizhen_hbu/stock_selection.git
lizhen_hbu
stock_selection
stock_selection
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385