通知设置 新通知
问一下,现在的“话题”可以由普通注册人员自行添加么?
默认分类 • 低调的哥哥 回复了问题 • 2 人关注 • 2 个回复 • 5962 次浏览 • 2016-07-25 08:41
tushare 源码分析 之 fundamental.py
量化交易-Ptrade-QMT • 李魔佛 发表了文章 • 0 个评论 • 16073 次浏览 • 2016-07-22 08:56
下面来具体看看里面的一些具体的函数是怎么实现的。
fundamental.py 这个文件是获取企业的基本面信息的。
比如 在主程序 main中,import tushare as ts
df=ts.get_stock_basics()那么我们来看看get_stock_basics函数的实现。def get_stock_basics():
"""
获取沪深上市公司基本情况
Return
--------
DataFrame
code,代码
name,名称
industry,细分行业
area,地区
pe,市盈率
outstanding,流通股本
totals,总股本(万)
totalAssets,总资产(万)
liquidAssets,流动资产
fixedAssets,固定资产
reserved,公积金
reservedPerShare,每股公积金
eps,每股收益
bvps,每股净资
pb,市净率
timeToMarket,上市日期
"""
request = Request(ct.ALL_STOCK_BASICS_FILE)
text = urlopen(request, timeout=10).read()
text = text.decode('GBK')
text = text.replace('--', '')
df = pd.read_csv(StringIO(text), dtype={'code':'object'})
df = df.set_index('code')
return df
上面通过urlib2的Request函数获取url的信息,然后保存为df格式然后返回。
url路径在这个变量里面:
ct.ALL_STOCK_BASICS_FILE
跳转到这个变量
ALL_STOCK_BASICS_FILE = '%s%s/static/all.csv'%(P_TYPE['http'], DOMAINS['oss'])
P_TYPE 和DOMAINS 是字典变量, 在同一个文件内可以找到他们的值:P_TYPE = {'http': 'http://', 'ftp': 'ftp://'}
DOMAINS = {'sina': 'sina.com.cn', 'sinahq': 'sinajs.cn',
'ifeng': 'ifeng.com', 'sf': 'finance.sina.com.cn',
'vsf': 'vip.stock.finance.sina.com.cn',
'idx': 'www.csindex.com.cn', '163': 'money.163.com',
'em': 'eastmoney.com', 'sseq': 'query.sse.com.cn',
'sse': 'www.sse.com.cn', 'szse': 'www.szse.cn',
'oss': '218.244.146.57', 'idxip':'115.29.204.48',
'shibor': 'www.shibor.org', 'mbox':'www.cbooo.cn'}
然后把上面的字典值抽取出来:
那么url就是 http://218.244.146.57/static/all.csv , 你可以试试在浏览器里直接输入。 看到了吗?
可以直接下载一个all.csv格式的文件,打开后可以看到里面很多企业基本面的信息。
获取业绩报表
def get_report_data(year, quarter):
"""
获取业绩报表数据
Parameters
--------
year:int 年度 e.g:2014
quarter:int 季度 :1、2、3、4,只能输入这4个季度
说明:由于是从网站获取的数据,需要一页页抓取,速度取决于您当前网络速度
Return
--------
DataFrame
code,代码
name,名称
eps,每股收益
eps_yoy,每股收益同比(%)
bvps,每股净资产
roe,净资产收益率(%)
epcf,每股现金流量(元)
net_profits,净利润(万元)
profits_yoy,净利润同比(%)
distrib,分配方案
report_date,发布日期
"""
函数主要通过 request = Request(url) 在财经网站获取信息。request = Request(ct.REPORT_URL%(ct.P_TYPE['http'], ct.DOMAINS['vsf'], ct.PAGES['fd'],year, quarter, pageNo, ct.PAGE_NUM[1]))
text = urlopen(request, timeout=10).read()
Request里面的参数是一个可变量,通过循环的列表来获取所有的公司业绩报表。
通过定位参数里的变量,可以得到随意一个url, 比如 REPORT_URL = '%s%s/q/go.php/vFinanceAnalyze/kind/mainindex/%s?s_i=&s_a=&s_c=&reportdate=%s&quarter=%s&p=%s&num=%s'
那么url =http://vip.stock.finance.sina.com.cn/q/go.php/vFinanceAnalyze/kind/mainindex/index.phtml?s_i=&s_a=&s_c=&reportdate=2014&quarter=1&p=1&num=38
那么直接在浏览器输入看看 是什么数据
看到了2014年第一节度的每个公司的业绩(因为有些是新股,所以2014的数据显示不全)
注意 df=ts.get_report_data(2016,4)
#第四季度就是年报
根据作者的意思,这个参数写4就是年报。 (可以自己根据网址内容去到新浪财经去验证)
新版tushare注册码
https://tushare.pro/register?reg=217168
注册后送积分,只有足够的积分才能够调用一些高权限的接口
待续。 查看全部
下面来具体看看里面的一些具体的函数是怎么实现的。
fundamental.py 这个文件是获取企业的基本面信息的。
比如 在主程序 main中,
import tushare as ts那么我们来看看get_stock_basics函数的实现。
df=ts.get_stock_basics()
def get_stock_basics():
"""
获取沪深上市公司基本情况
Return
--------
DataFrame
code,代码
name,名称
industry,细分行业
area,地区
pe,市盈率
outstanding,流通股本
totals,总股本(万)
totalAssets,总资产(万)
liquidAssets,流动资产
fixedAssets,固定资产
reserved,公积金
reservedPerShare,每股公积金
eps,每股收益
bvps,每股净资
pb,市净率
timeToMarket,上市日期
"""
request = Request(ct.ALL_STOCK_BASICS_FILE)
text = urlopen(request, timeout=10).read()
text = text.decode('GBK')
text = text.replace('--', '')
df = pd.read_csv(StringIO(text), dtype={'code':'object'})
df = df.set_index('code')
return df
上面通过urlib2的Request函数获取url的信息,然后保存为df格式然后返回。
url路径在这个变量里面:
ct.ALL_STOCK_BASICS_FILE
跳转到这个变量
ALL_STOCK_BASICS_FILE = '%s%s/static/all.csv'%(P_TYPE['http'], DOMAINS['oss'])
P_TYPE 和DOMAINS 是字典变量, 在同一个文件内可以找到他们的值:
P_TYPE = {'http': 'http://', 'ftp': 'ftp://'}
DOMAINS = {'sina': 'sina.com.cn', 'sinahq': 'sinajs.cn',
'ifeng': 'ifeng.com', 'sf': 'finance.sina.com.cn',
'vsf': 'vip.stock.finance.sina.com.cn',
'idx': 'www.csindex.com.cn', '163': 'money.163.com',
'em': 'eastmoney.com', 'sseq': 'query.sse.com.cn',
'sse': 'www.sse.com.cn', 'szse': 'www.szse.cn',
'oss': '218.244.146.57', 'idxip':'115.29.204.48',
'shibor': 'www.shibor.org', 'mbox':'www.cbooo.cn'}然后把上面的字典值抽取出来:
那么url就是 http://218.244.146.57/static/all.csv , 你可以试试在浏览器里直接输入。 看到了吗?
可以直接下载一个all.csv格式的文件,打开后可以看到里面很多企业基本面的信息。
获取业绩报表
def get_report_data(year, quarter):
"""
获取业绩报表数据
Parameters
--------
year:int 年度 e.g:2014
quarter:int 季度 :1、2、3、4,只能输入这4个季度
说明:由于是从网站获取的数据,需要一页页抓取,速度取决于您当前网络速度
Return
--------
DataFrame
code,代码
name,名称
eps,每股收益
eps_yoy,每股收益同比(%)
bvps,每股净资产
roe,净资产收益率(%)
epcf,每股现金流量(元)
net_profits,净利润(万元)
profits_yoy,净利润同比(%)
distrib,分配方案
report_date,发布日期
"""
函数主要通过 request = Request(url) 在财经网站获取信息。
request = Request(ct.REPORT_URL%(ct.P_TYPE['http'], ct.DOMAINS['vsf'], ct.PAGES['fd'],year, quarter, pageNo, ct.PAGE_NUM[1]))
text = urlopen(request, timeout=10).read()
Request里面的参数是一个可变量,通过循环的列表来获取所有的公司业绩报表。
通过定位参数里的变量,可以得到随意一个url, 比如 REPORT_URL = '%s%s/q/go.php/vFinanceAnalyze/kind/mainindex/%s?s_i=&s_a=&s_c=&reportdate=%s&quarter=%s&p=%s&num=%s'
那么url =http://vip.stock.finance.sina.com.cn/q/go.php/vFinanceAnalyze/kind/mainindex/index.phtml?s_i=&s_a=&s_c=&reportdate=2014&quarter=1&p=1&num=38
那么直接在浏览器输入看看 是什么数据
看到了2014年第一节度的每个公司的业绩(因为有些是新股,所以2014的数据显示不全)
注意
df=ts.get_report_data(2016,4)
#第四季度就是年报
根据作者的意思,这个参数写4就是年报。 (可以自己根据网址内容去到新浪财经去验证)
新版tushare注册码
https://tushare.pro/register?reg=217168
注册后送积分,只有足够的积分才能够调用一些高权限的接口
待续。
30天学会量化交易模型 Day05
量化交易-Ptrade-QMT • 李魔佛 发表了文章 • 7 个评论 • 14117 次浏览 • 2016-07-19 22:52
这一节 我们学习如何把得到的数据写入数据库。
虽然也可以写入excel或者json,不过考虑到后面用的的排序和其他python脚本的调用,最后选择了轻量级的数据库SQLiite作为首选。# -*-coding=utf-8-*-
#数据库的操作
'''
http://30daydo.com
weigesysu@qq.com
'''
import sqlite3, time, datetime
__author__ = 'rocky'
class SqliteDb():
def __init__(self,dbtable):
'''
self.today = time.strftime("%Y-%m-%d")
self.DBname = self.today + '.db'
self.conn = sqlite3.connect(self.DBname)
'''
today = time.strftime("%Y-%m-%d")
DBname = today + '.db'
self.conn = sqlite3.connect(DBname)
self.dbtable=dbtable
create_tb = "CREATE TABLE %s (date varchar(10),id varchar(6), name varchar(30), p_change REAL,turnover REAL);" %self.dbtable
self.conn.execute(create_tb)
self.conn.commit()
def store_break_high(self,price_high_data):
#data 是创新高的个股信息 dataframe
#print today
#create_tb = 'CREATE TABLE STOCK (date TEXT,id text PRIMARY KEY, p_change REAL,turnover REAL);'
#conn.commit()
#print "(%s,%s,%f,%f)" %(price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3])
insert_data_cmd = "INSERT INTO %s(date,id,name,p_change,turnover) VALUES(\"%s\",\"%s\",\"%s\",%f,%f);" %(self.dbtable,price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3],price_high_data[4])
self.conn.execute(insert_data_cmd)
#self.conn.execute('INSERT INTO STOCK(date,id,name,p_change,turnover) VALUES(?,?,?,?,?)',(price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3],price_high_data[4]))
self.conn.commit()
def close(self):
self.conn.close()
上面创建的表名是 以日期为命名的(前面的下划线是因为数据库的命名规则不能以数字为首)
上一篇:30天学会量化交易模型 Day04 (tushare获取破新高的股票)
http://www.30daydo.com/article/70 查看全部
这一节 我们学习如何把得到的数据写入数据库。
虽然也可以写入excel或者json,不过考虑到后面用的的排序和其他python脚本的调用,最后选择了轻量级的数据库SQLiite作为首选。
# -*-coding=utf-8-*-
#数据库的操作
'''
http://30daydo.com
weigesysu@qq.com
'''
import sqlite3, time, datetime
__author__ = 'rocky'
class SqliteDb():
def __init__(self,dbtable):
'''
self.today = time.strftime("%Y-%m-%d")
self.DBname = self.today + '.db'
self.conn = sqlite3.connect(self.DBname)
'''
today = time.strftime("%Y-%m-%d")
DBname = today + '.db'
self.conn = sqlite3.connect(DBname)
self.dbtable=dbtable
create_tb = "CREATE TABLE %s (date varchar(10),id varchar(6), name varchar(30), p_change REAL,turnover REAL);" %self.dbtable
self.conn.execute(create_tb)
self.conn.commit()
def store_break_high(self,price_high_data):
#data 是创新高的个股信息 dataframe
#print today
#create_tb = 'CREATE TABLE STOCK (date TEXT,id text PRIMARY KEY, p_change REAL,turnover REAL);'
#conn.commit()
#print "(%s,%s,%f,%f)" %(price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3])
insert_data_cmd = "INSERT INTO %s(date,id,name,p_change,turnover) VALUES(\"%s\",\"%s\",\"%s\",%f,%f);" %(self.dbtable,price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3],price_high_data[4])
self.conn.execute(insert_data_cmd)
#self.conn.execute('INSERT INTO STOCK(date,id,name,p_change,turnover) VALUES(?,?,?,?,?)',(price_high_data[0], price_high_data[1], price_high_data[2], price_high_data[3],price_high_data[4]))
self.conn.commit()
def close(self):
self.conn.close()
上面创建的表名是 以日期为命名的(前面的下划线是因为数据库的命名规则不能以数字为首)
上一篇:30天学会量化交易模型 Day04 (tushare获取破新高的股票)
http://www.30daydo.com/article/70
SQL 笔记 (新人会遇到的坑)
Linux • 李魔佛 发表了文章 • 0 个评论 • 3607 次浏览 • 2016-07-18 22:31
这里记录下来,说不定除了能够提醒自己,还能够帮助别人。
1. SQL的表名命名规则跟C,C++的变量命名规则一样,只能包含数字,字母,下划线。 而且不能够以数字开头。
(之前曾经很傻的用日期作为表名,结果一堆报错的。
如果硬要用日期,不妨在前面放一个下划线。
)
查看全部
使用pandas的dataframe数据进行操作的总结
python • 李魔佛 发表了文章 • 0 个评论 • 6667 次浏览 • 2016-07-17 16:47
#使用iloc后,t已经变成了一个子集。 已经不再是一个dataframe数据。 所以你使用 t['high'] 返回的是一个值。此时t已经没有index了,如果这个时候调用 t.index
t=df[:1]
class 'pandas.core.frame.DataFrame'>
#这是返回的是一个DataFrame的一个子集。 此时 你可以继续用dateFrame的一些方法进行操作。
删除dataframe中某一行
df.drop()
df的内容如下:
df.drop(df[df[u'代码']==300141.0].index,inplace=True)
print df
输出如下
记得参数inplace=True, 因为默认的值为inplace=False,意思就是你不添加的话就使用Falase这个值。
这样子原来的df不会被修改, 只是会返回新的修改过的df。 这样的话需要用一个新变量来承接它
new_df=df.drop(df[df[u'代码']==300141.0].index)
判断DataFrame为None
if df is None:
print "None len==0"
return False
查看全部
#使用iloc后,t已经变成了一个子集。 已经不再是一个dataframe数据。 所以你使用 t['high'] 返回的是一个值。此时t已经没有index了,如果这个时候调用 t.index
t=df[:1]
class 'pandas.core.frame.DataFrame'>
#这是返回的是一个DataFrame的一个子集。 此时 你可以继续用dateFrame的一些方法进行操作。
删除dataframe中某一行
df.drop()
df的内容如下:
df.drop(df[df[u'代码']==300141.0].index,inplace=True)
print df
输出如下
记得参数inplace=True, 因为默认的值为inplace=False,意思就是你不添加的话就使用Falase这个值。
这样子原来的df不会被修改, 只是会返回新的修改过的df。 这样的话需要用一个新变量来承接它
new_df=df.drop(df[df[u'代码']==300141.0].index)
判断DataFrame为None
if df is None:
print "None len==0"
return False
30天学会量化交易模型 Day04
量化交易-Ptrade-QMT • 李魔佛 发表了文章 • 4 个评论 • 22705 次浏览 • 2016-07-16 21:28
股市有句话,新高后有新高。
因为新高后说明消化了前面的套牢盘。 所以这个时候的阻力很小。
下面使用一个例子来用代码获取当天创新高的股票。
使用的是tushare#-*-coding=utf-8-*-
__author__ = 'rocky'
'''
http://30daydo.com
weigesysu@qq.com
'''
#获取破指定天数内的新高 比如破60日新高
import tushare as ts
import datetime
info=ts.get_stock_basics()
def loop_all_stocks():
for EachStockID in info.index:
if is_break_high(EachStockID,60):
print "High price on",
print EachStockID,
print info.ix[EachStockID]['name'].decode('utf-8')
def is_break_high(stockID,days):
end_day=datetime.date(datetime.date.today().year,datetime.date.today().month,datetime.date.today().day)
days=days*7/5
#考虑到周六日非交易
start_day=end_day-datetime.timedelta(days)
start_day=start_day.strftime("%Y-%m-%d")
end_day=end_day.strftime("%Y-%m-%d")
df=ts.get_h_data(stockID,start=start_day,end=end_day)
period_high=df['high'].max()
#print period_high
today_high=df.iloc[0]['high']
#这里不能直接用 .values
#如果用的df【:1】 就需要用.values
#print today_high
if today_high>=period_high:
return True
else:
return False
loop_all_stocks()
可以修改 函数 is_break_high(EachStockID,60) 中的60 为破多少天内的新高。
上一篇:30天学会量化交易模型 Day03
http://www.30daydo.com/article/15
下一篇: 30天学会量化交易模型 Day05 (tushare数据写入SQLite)
http://www.30daydo.com/article/73 查看全部
股市有句话,新高后有新高。
因为新高后说明消化了前面的套牢盘。 所以这个时候的阻力很小。
下面使用一个例子来用代码获取当天创新高的股票。
使用的是tushare
#-*-coding=utf-8-*-
__author__ = 'rocky'
'''
http://30daydo.com
weigesysu@qq.com
'''
#获取破指定天数内的新高 比如破60日新高
import tushare as ts
import datetime
info=ts.get_stock_basics()
def loop_all_stocks():
for EachStockID in info.index:
if is_break_high(EachStockID,60):
print "High price on",
print EachStockID,
print info.ix[EachStockID]['name'].decode('utf-8')
def is_break_high(stockID,days):
end_day=datetime.date(datetime.date.today().year,datetime.date.today().month,datetime.date.today().day)
days=days*7/5
#考虑到周六日非交易
start_day=end_day-datetime.timedelta(days)
start_day=start_day.strftime("%Y-%m-%d")
end_day=end_day.strftime("%Y-%m-%d")
df=ts.get_h_data(stockID,start=start_day,end=end_day)
period_high=df['high'].max()
#print period_high
today_high=df.iloc[0]['high']
#这里不能直接用 .values
#如果用的df【:1】 就需要用.values
#print today_high
if today_high>=period_high:
return True
else:
return False
loop_all_stocks()
可以修改 函数 is_break_high(EachStockID,60) 中的60 为破多少天内的新高。
上一篇:30天学会量化交易模型 Day03
http://www.30daydo.com/article/15
下一篇: 30天学会量化交易模型 Day05 (tushare数据写入SQLite)
http://www.30daydo.com/article/73
安卓系统常用命令 adb shell
Android • 李魔佛 发表了文章 • 0 个评论 • 4789 次浏览 • 2016-07-16 16:44
1. 安卓关机(非重启): adb shell svc power shutdown
2. android开机的时候跳过初始化设置 (setup wizard): adb shell input text 1396611460
3.
1. 安卓关机(非重启): adb shell svc power shutdown
2. android开机的时候跳过初始化设置 (setup wizard): adb shell input text 1396611460
3.
汇金(国家队)最近增持的个股 2016年4月之后
股票 • 李魔佛 发表了文章 • 0 个评论 • 3173 次浏览 • 2016-07-14 22:59
有点意思,个人猜测,有可能是养老金悄悄进入的市场。
保持关注。
雪人股份 继续跟踪 7月12日
股票 • 李魔佛 发表了文章 • 0 个评论 • 3443 次浏览 • 2016-07-12 08:26
所以后期还是可以再介入一波。
雪人股份 后续分析 6月30日 查看全部
所以后期还是可以再介入一波。
雪人股份 后续分析 6月30日
python 爬虫下载的图片打不开?
python • 李魔佛 发表了文章 • 0 个评论 • 7885 次浏览 • 2016-07-09 17:33
代码如下片段
__author__ = 'rocky'
import urllib,urllib2,StringIO,gzip
url="http://image.xitek.com/photo/2 ... ot%3B
filname=url.split("/")[-1]
req=urllib2.Request(url)
resp=urllib2.urlopen(req)
content=resp.read()
#data = StringIO.StringIO(content)
#gzipper = gzip.GzipFile(fileobj=data)
#html = gzipper.read()
f=open(filname,'w')
f.write()
f.close()
运行后生成的文件打开后不显示图片。
后来调试后发现,如果要保存为图片格式, 文件的读写需要用'wb', 也就是上面代码中
f=open(filname,'w') 改一下 改成
f=open(filname,'wb')
就可以了。
查看全部
代码如下片段
__author__ = 'rocky'运行后生成的文件打开后不显示图片。
import urllib,urllib2,StringIO,gzip
url="http://image.xitek.com/photo/2 ... ot%3B
filname=url.split("/")[-1]
req=urllib2.Request(url)
resp=urllib2.urlopen(req)
content=resp.read()
#data = StringIO.StringIO(content)
#gzipper = gzip.GzipFile(fileobj=data)
#html = gzipper.read()
f=open(filname,'w')
f.write()
f.close()
后来调试后发现,如果要保存为图片格式, 文件的读写需要用'wb', 也就是上面代码中
f=open(filname,'w') 改一下 改成
f=open(filname,'wb')
就可以了。
判断网页内容是否经过gzip压缩 python代码
python • 李魔佛 发表了文章 • 0 个评论 • 4687 次浏览 • 2016-07-09 15:10
那么可以在代码中添加一个判断,判断网页内容是否经过gzip压缩,是的话多一个处理就可以了。
深港通标的个股 -- 年内定会开通
股票 • 李魔佛 发表了文章 • 0 个评论 • 3527 次浏览 • 2016-07-07 12:03
linux locate 搜索挂载的分区文件
Linux • 李魔佛 发表了文章 • 0 个评论 • 3536 次浏览 • 2016-07-07 11:17
可以修改updatedb的配置文件来修改sudo gedit /etc/updatedb.conf
把文件中的PRUNEPATHS="/tmp /var/spool /media /home/.ecryptfs"
/media 去掉就可以了。
这个参数是设置忽略哪些查找的路径。
查看全部
一般linux的locate命令会忽略挂载分区的文件,所以即使你挂载分区后使用updatedb也没用。
可以修改updatedb的配置文件来修改
sudo gedit /etc/updatedb.conf
把文件中的
PRUNEPATHS="/tmp /var/spool /media /home/.ecryptfs"
/media 去掉就可以了。
这个参数是设置忽略哪些查找的路径。
股市中的数学 (1)
股票 • 李魔佛 发表了文章 • 0 个评论 • 3783 次浏览 • 2016-07-02 09:54
股价连续n个涨停板后的涨幅是 = (1.1的n次方 -1 )
比如, 新股连续一周涨停板,那么一周的涨幅就是 1.1(**5)-1=61%
1 day's raise is 10.00
2 day's raise is 21.00
3 day's raise is 33.10
4 day's raise is 46.41
5 day's raise is 61.05
查看全部
股价连续n个涨停板后的涨幅是 = (1.1的n次方 -1 )
比如, 新股连续一周涨停板,那么一周的涨幅就是 1.1(**5)-1=61%
1 day's raise is 10.00
2 day's raise is 21.00
3 day's raise is 33.10
4 day's raise is 46.41
5 day's raise is 61.05
定向增发与非公开发行
量化交易 • 李魔佛 发表了文章 • 0 个评论 • 4423 次浏览 • 2016-07-01 23:14
定向增发与非公开发行目前已经是一个概念了。
定向增发是指上市公司向符合条件的少数特定投资者非公开发行股份的行为,规定要求发行对象不得超过10人,发行价不得低于公告前20个交易市价的90%,发行股份12个月内(认购后变成控股股东或拥有实际控制权的36个月内) 不得转让。
2006年证监会推出的《再融资管理办法》中,关于非公开发行,除了规定发行对象不得超过10人,发行价不得低于市价的90%,发行股份12个月内(大股东认购的为36个月)不得转让,以及募资用途需符合国家产业政策、上市公司及其高管不得有违规行为等外,没有其他条件。
感觉不公开的东西才是好东东~
非定向增发的估计都是没人要的。。 查看全部
定向增发与非公开发行目前已经是一个概念了。
定向增发是指上市公司向符合条件的少数特定投资者非公开发行股份的行为,规定要求发行对象不得超过10人,发行价不得低于公告前20个交易市价的90%,发行股份12个月内(认购后变成控股股东或拥有实际控制权的36个月内) 不得转让。
2006年证监会推出的《再融资管理办法》中,关于非公开发行,除了规定发行对象不得超过10人,发行价不得低于市价的90%,发行股份12个月内(大股东认购的为36个月)不得转让,以及募资用途需符合国家产业政策、上市公司及其高管不得有违规行为等外,没有其他条件。
感觉不公开的东西才是好东东~
非定向增发的估计都是没人要的。。
python 编写火车票抢票软件
python • 李魔佛 发表了文章 • 2 个评论 • 14907 次浏览 • 2016-06-30 15:55
实现日期:2016.7.30
实现日期:2016.7.30
python 获取 中国证券网 的公告
python爬虫 • 李魔佛 发表了文章 • 11 个评论 • 26259 次浏览 • 2016-06-30 15:45
这个网站的公告会比同花顺东方财富的早一点,而且还出现过早上中国证券网已经发了公告,而东财却拿去做午间公告,以至于可以提前获取公告提前埋伏。
现在程序自动把抓取的公告存入本网站中:http://30daydo.com/news.php
每天早上8:30更新一次。
生成的公告保存在stock/文件夹下,以日期命名。 下面脚本是循坏检测,如果有新的公告就会继续生成。
默认保存前3页的公告。(一次过太多页会被网站暂时屏蔽几分钟)。 代码以及使用了切换header来躲避网站的封杀。
修改
getInfo(3) 里面的数字就可以抓取前面某页数据
__author__ = 'rocchen'
# working v1.0
from bs4 import BeautifulSoup
import urllib2, datetime, time, codecs, cookielib, random, threading
import os,sys
def getInfo(max_index_user=5):
stock_news_site =
"http://ggjd.cnstock.com/gglist/search/ggkx/"
my_userAgent = [
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11',
'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)']
index = 0
max_index = max_index_user
num = 1
temp_time = time.strftime("[%Y-%m-%d]-[%H-%M]", time.localtime())
store_filename = "StockNews-%s.log" % temp_time
fOpen = codecs.open(store_filename, 'w', 'utf-8')
while index < max_index:
user_agent = random.choice(my_userAgent)
# print user_agent
company_news_site = stock_news_site + str(index)
# content = urllib2.urlopen(company_news_site)
headers = {'User-Agent': user_agent, 'Host': "ggjd.cnstock.com", 'DNT': '1',
'Accept': 'text/html, application/xhtml+xml, */*', }
req = urllib2.Request(url=company_news_site, headers=headers)
resp = None
raw_content = ""
try:
resp = urllib2.urlopen(req, timeout=30)
except urllib2.HTTPError as e:
e.fp.read()
except urllib2.URLError as e:
if hasattr(e, 'code'):
print "error code %d" % e.code
elif hasattr(e, 'reason'):
print "error reason %s " % e.reason
finally:
if resp:
raw_content = resp.read()
time.sleep(2)
resp.close()
soup = BeautifulSoup(raw_content, "html.parser")
all_content = soup.find_all("span", "time")
for i in all_content:
news_time = i.string
node = i.next_sibling
str_temp = "No.%s \n%s\t%s\n---> %s \n\n" % (str(num), news_time, node['title'], node['href'])
#print "inside %d" %num
#print str_temp
fOpen.write(str_temp)
num = num + 1
#print "index %d" %index
index = index + 1
fOpen.close()
def execute_task(n=60):
period = int(n)
while True:
print datetime.datetime.now()
getInfo(3)
time.sleep(60 * period)
if __name__ == "__main__":
sub_folder = os.path.join(os.getcwd(), "stock")
if not os.path.exists(sub_folder):
os.mkdir(sub_folder)
os.chdir(sub_folder)
start_time = time.time() # user can change the max index number getInfo(10), by default is getInfo(5)
if len(sys.argv) <2:
n = raw_input("Input Period : ? mins to download every cycle")
else:
n=int(sys.argv[1])
execute_task(n)
end_time = time.time()
print "Total time: %s s." % str(round((end_time - start_time), 4))
github:https://github.com/Rockyzsu/cnstock
查看全部
这个网站的公告会比同花顺东方财富的早一点,而且还出现过早上中国证券网已经发了公告,而东财却拿去做午间公告,以至于可以提前获取公告提前埋伏。
现在程序自动把抓取的公告存入本网站中:http://30daydo.com/news.php
每天早上8:30更新一次。
生成的公告保存在stock/文件夹下,以日期命名。 下面脚本是循坏检测,如果有新的公告就会继续生成。
默认保存前3页的公告。(一次过太多页会被网站暂时屏蔽几分钟)。 代码以及使用了切换header来躲避网站的封杀。
修改
getInfo(3) 里面的数字就可以抓取前面某页数据
__author__ = 'rocchen'
# working v1.0
from bs4 import BeautifulSoup
import urllib2, datetime, time, codecs, cookielib, random, threading
import os,sys
def getInfo(max_index_user=5):
stock_news_site =
"http://ggjd.cnstock.com/gglist/search/ggkx/"
my_userAgent = [
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0',
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11',
'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)']
index = 0
max_index = max_index_user
num = 1
temp_time = time.strftime("[%Y-%m-%d]-[%H-%M]", time.localtime())
store_filename = "StockNews-%s.log" % temp_time
fOpen = codecs.open(store_filename, 'w', 'utf-8')
while index < max_index:
user_agent = random.choice(my_userAgent)
# print user_agent
company_news_site = stock_news_site + str(index)
# content = urllib2.urlopen(company_news_site)
headers = {'User-Agent': user_agent, 'Host': "ggjd.cnstock.com", 'DNT': '1',
'Accept': 'text/html, application/xhtml+xml, */*', }
req = urllib2.Request(url=company_news_site, headers=headers)
resp = None
raw_content = ""
try:
resp = urllib2.urlopen(req, timeout=30)
except urllib2.HTTPError as e:
e.fp.read()
except urllib2.URLError as e:
if hasattr(e, 'code'):
print "error code %d" % e.code
elif hasattr(e, 'reason'):
print "error reason %s " % e.reason
finally:
if resp:
raw_content = resp.read()
time.sleep(2)
resp.close()
soup = BeautifulSoup(raw_content, "html.parser")
all_content = soup.find_all("span", "time")
for i in all_content:
news_time = i.string
node = i.next_sibling
str_temp = "No.%s \n%s\t%s\n---> %s \n\n" % (str(num), news_time, node['title'], node['href'])
#print "inside %d" %num
#print str_temp
fOpen.write(str_temp)
num = num + 1
#print "index %d" %index
index = index + 1
fOpen.close()
def execute_task(n=60):
period = int(n)
while True:
print datetime.datetime.now()
getInfo(3)
time.sleep(60 * period)
if __name__ == "__main__":
sub_folder = os.path.join(os.getcwd(), "stock")
if not os.path.exists(sub_folder):
os.mkdir(sub_folder)
os.chdir(sub_folder)
start_time = time.time() # user can change the max index number getInfo(10), by default is getInfo(5)
if len(sys.argv) <2:
n = raw_input("Input Period : ? mins to download every cycle")
else:
n=int(sys.argv[1])
execute_task(n)
end_time = time.time()
print "Total time: %s s." % str(round((end_time - start_time), 4))
github:https://github.com/Rockyzsu/cnstock
雪人股份 后续分析 6月30日
股票 • 李魔佛 发表了文章 • 0 个评论 • 3749 次浏览 • 2016-06-30 09:05
从27日的龙虎榜信息来看
卖出方并没有出现福州五一路,说明该营业部进行了锁仓。 而从最近2天的调整的套路来看,成交量减少了一半,主力不可能在2天缩量的时候把货出掉,所以判断是锁仓。。 分时上看,一旦股价下跌到最低点(下图中的红圈),就有大单涌进来吸货。 从而并未造成股价大幅下跌。
如果庄家跑路,那么股价就会随自由落体,价格波动幅度会很大。
所有雪人后续还会有一批,建议目前小仓位建仓,等股价拉起来可以继续加仓。
雪人股份 分析贴:
雪人股份 后续分析 6月22日
雪人股份 大宗交易分析 寻找主力痕迹
查看全部
从27日的龙虎榜信息来看
卖出方并没有出现福州五一路,说明该营业部进行了锁仓。 而从最近2天的调整的套路来看,成交量减少了一半,主力不可能在2天缩量的时候把货出掉,所以判断是锁仓。。 分时上看,一旦股价下跌到最低点(下图中的红圈),就有大单涌进来吸货。 从而并未造成股价大幅下跌。
如果庄家跑路,那么股价就会随自由落体,价格波动幅度会很大。
所有雪人后续还会有一批,建议目前小仓位建仓,等股价拉起来可以继续加仓。
雪人股份 分析贴:
雪人股份 后续分析 6月22日
雪人股份 大宗交易分析 寻找主力痕迹
为什么beautifulsoup的children不能用列表索引index去返回值 ?
回复python • 李魔佛 回复了问题 • 1 人关注 • 1 个回复 • 8065 次浏览 • 2016-06-29 22:10
python 下使用beautifulsoup还是lxml ?
python • 李魔佛 发表了文章 • 0 个评论 • 8349 次浏览 • 2016-06-29 18:29
然后看了下beautifulsoup的源码,其实现原理使用的是正则表达式,而lxml使用的节点递归的技术。
Don't use BeautifulSoup, use lxml.soupparser then you're sitting on top of the power of lxml and can use the good bits of BeautifulSoup which is to deal with really broken and crappy HTML.
9down vote
In summary, lxml is positioned as a lightning-fast production-quality html and xml parser that, by the way, also includes a soupparser module to fall back on BeautifulSoup's functionality. BeautifulSoupis a one-person project, designed to save you time to quickly extract data out of poorly-formed html or xml.
lxml documentation says that both parsers have advantages and disadvantages. For this reason, lxml provides a soupparser so you can switch back and forth. Quoting,
[quote]
BeautifulSoup uses a different parsing approach. It is not a real HTML parser but uses regular expressions to dive through tag soup. It is therefore more forgiving in some cases and less good in others. It is not uncommon that lxml/libxml2 parses and fixes broken HTML better, but BeautifulSoup has superiour support for encoding detection. It very much depends on the input which parser works better.
In the end they are saying,
The downside of using this parser is that it is much slower than the HTML parser of lxml. So if performance matters, you might want to consider using soupparser only as a fallback for certain cases.
If I understand them correctly, it means that the soup parser is more robust --- it can deal with a "soup" of malformed tags by using regular expressions --- whereas lxml is more straightforward and just parses things and builds a tree as you would expect. I assume it also applies to BeautifulSoup itself, not just to the soupparser for lxml.
They also show how to benefit from BeautifulSoup's encoding detection, while still parsing quickly with lxml:[code]>>> from BeautifulSoup import UnicodeDammit
>>> def decode_html(html_string):
... converted = UnicodeDammit(html_string, isHTML=True)
... if not converted.unicode:
... raise UnicodeDecodeError(
... "Failed to detect encoding, tried [%s]",
... ', '.join(converted.triedEncodings))
... # print converted.originalEncoding
... return converted.unicode
>>> root = lxml.html.fromstring(decode_html(tag_soup))[/code]
(Same source: http://lxml.de/elementsoup.html).
In words of BeautifulSoup's creator,
That's it! Have fun! I wrote Beautiful Soup to save everybody time. Once you get used to it, you should be able to wrangle data out of poorly-designed websites in just a few minutes. Send me email if you have any comments, run into problems, or want me to know about your project that uses Beautiful Soup.[code] --Leonard[/code]
Quoted from the Beautiful Soup documentation.
I hope this is now clear. The soup is a brilliant one-person project designed to save you time to extract data out of poorly-designed websites. The goal is to save you time right now, to get the job done, not necessarily to save you time in the long term, and definitely not to optimize the performance of your software.
Also, from the lxml website,
lxml has been downloaded from the Python Package Index more than two million times and is also available directly in many package distributions, e.g. for Linux or MacOS-X.
And, from Why lxml?,
The C libraries libxml2 and libxslt have huge benefits:... Standards-compliant... Full-featured... fast. fast! FAST! ... lxml is a new Python binding for libxml2 and libxslt...
[/quote]
意思大概就是 不要用Beautifulsoup,使用lxml, lxml才能让你提要到让你体会到html节点解析的速度之快。
查看全部
然后看了下beautifulsoup的源码,其实现原理使用的是正则表达式,而lxml使用的节点递归的技术。
Don't use BeautifulSoup, use lxml.soupparser then you're sitting on top of the power of lxml and can use the good bits of BeautifulSoup which is to deal with really broken and crappy HTML.
9down vote
In summary,lxmlis positioned as a lightning-fast production-quality html and xml parser that, by the way, also includes asoupparsermodule to fall back on BeautifulSoup's functionality.BeautifulSoupis a one-person project, designed to save you time to quickly extract data out of poorly-formed html or xml.
lxml documentation says that both parsers have advantages and disadvantages. For this reason,lxmlprovides asoupparserso you can switch back and forth. Quoting,
[quote]
BeautifulSoup uses a different parsing approach. It is not a real HTML parser but uses regular expressions to dive through tag soup. It is therefore more forgiving in some cases and less good in others. It is not uncommon that lxml/libxml2 parses and fixes broken HTML better, but BeautifulSoup has superiour support for encoding detection. It very much depends on the input which parser works better.
In the end they are saying,
The downside of using this parser is that it is much slower than the HTML parser of lxml. So if performance matters, you might want to consider using soupparser only as a fallback for certain cases.
If I understand them correctly, it means that the soup parser is more robust --- it can deal with a "soup" of malformed tags by using regular expressions --- whereas
lxmlis more straightforward and just parses things and builds a tree as you would expect. I assume it also applies to
BeautifulSoupitself, not just to the
soupparserfor
lxml.
They also show how to benefit from
BeautifulSoup's encoding detection, while still parsing quickly with
lxml:
[code]>>> from BeautifulSoup import UnicodeDammit[/code]
>>> def decode_html(html_string):
... converted = UnicodeDammit(html_string, isHTML=True)
... if not converted.unicode:
... raise UnicodeDecodeError(
... "Failed to detect encoding, tried [%s]",
... ', '.join(converted.triedEncodings))
... # print converted.originalEncoding
... return converted.unicode
>>> root = lxml.html.fromstring(decode_html(tag_soup))
(Same source: http://lxml.de/elementsoup.html).
In words of
BeautifulSoup's creator,
That's it! Have fun! I wrote Beautiful Soup to save everybody time. Once you get used to it, you should be able to wrangle data out of poorly-designed websites in just a few minutes. Send me email if you have any comments, run into problems, or want me to know about your project that uses Beautiful Soup.[code] --Leonard[/code]
Quoted from the Beautiful Soup documentation.
I hope this is now clear. The soup is a brilliant one-person project designed to save you time to extract data out of poorly-designed websites. The goal is to save you time right now, to get the job done, not necessarily to save you time in the long term, and definitely not to optimize the performance of your software.
Also, from the lxml website,
lxml has been downloaded from the Python Package Index more than two million times and is also available directly in many package distributions, e.g. for Linux or MacOS-X.
And, from Why lxml?,
The C libraries libxml2 and libxslt have huge benefits:... Standards-compliant... Full-featured... fast. fast! FAST! ... lxml is a new Python binding for libxml2 and libxslt...
[/quote]
意思大概就是 不要用Beautifulsoup,使用lxml, lxml才能让你提要到让你体会到html节点解析的速度之快。
python 批量获取色影无忌 获奖图片
python爬虫 • 李魔佛 发表了文章 • 6 个评论 • 17749 次浏览 • 2016-06-29 16:41
不多说,直接来代码:#-*-coding=utf-8-*-
__author__ = 'rocky chen'
from bs4 import BeautifulSoup
import urllib2,sys,StringIO,gzip,time,random,re,urllib,os
reload(sys)
sys.setdefaultencoding('utf-8')
class Xitek():
def __init__(self):
self.url="http://photo.xitek.com/"
user_agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
self.headers={"User-Agent":user_agent}
self.last_page=self.__get_last_page()
def __get_last_page(self):
html=self.__getContentAuto(self.url)
bs=BeautifulSoup(html,"html.parser")
page=bs.find_all('a',class_="blast")
last_page=page[0]['href'].split('/')[-1]
return int(last_page)
def __getContentAuto(self,url):
req=urllib2.Request(url,headers=self.headers)
resp=urllib2.urlopen(req)
#time.sleep(2*random.random())
content=resp.read()
info=resp.info().get("Content-Encoding")
if info==None:
return content
else:
t=StringIO.StringIO(content)
gziper=gzip.GzipFile(fileobj=t)
html = gziper.read()
return html
#def __getFileName(self,stream):
def __download(self,url):
p=re.compile(r'href="(/photoid/\d+)"')
#html=self.__getContentNoZip(url)
html=self.__getContentAuto(url)
content = p.findall(html)
for i in content:
print i
photoid=self.__getContentAuto(self.url+i)
bs=BeautifulSoup(photoid,"html.parser")
final_link=bs.find('img',class_="mimg")['src']
print final_link
#pic_stream=self.__getContentAuto(final_link)
title=bs.title.string.strip()
filename = re.sub('[\/:*?"<>|]', '-', title)
filename=filename+'.jpg'
urllib.urlretrieve(final_link,filename)
#f=open(filename,'w')
#f.write(pic_stream)
#f.close()
#print html
#bs=BeautifulSoup(html,"html.parser")
#content=bs.find_all(p)
#for i in content:
# print i
'''
print bs.title
element_link=bs.find_all('div',class_="element")
print len(element_link)
k=1
for href in element_link:
#print type(href)
#print href.tag
'''
'''
if href.children[0]:
print href.children[0]
'''
'''
t=0
for i in href.children:
#if i.a:
if t==0:
#print k
if i['href']
print link
if p.findall(link):
full_path=self.url[0:len(self.url)-1]+link
sub_html=self.__getContent(full_path)
bs=BeautifulSoup(sub_html,"html.parser")
final_link=bs.find('img',class_="mimg")['src']
#time.sleep(2*random.random())
print final_link
#k=k+1
#print type(i)
#print i.tag
#if hasattr(i,"href"):
#print i['href']
#print i.tag
t=t+1
#print "*"
'''
'''
if href:
if href.children:
print href.children[0]
'''
#print "one element link"
def getPhoto(self):
start=0
#use style/0
photo_url="http://photo.xitek.com/style/0/p/"
for i in range(start,self.last_page+1):
url=photo_url+str(i)
print url
#time.sleep(1)
self.__download(url)
'''
url="http://photo.xitek.com/style/0/p/10"
self.__download(url)
'''
#url="http://photo.xitek.com/style/0/p/0"
#html=self.__getContent(url)
#url="http://photo.xitek.com/"
#html=self.__getContentNoZip(url)
#print html
#'''
def main():
sub_folder = os.path.join(os.getcwd(), "content")
if not os.path.exists(sub_folder):
os.mkdir(sub_folder)
os.chdir(sub_folder)
obj=Xitek()
obj.getPhoto()
if __name__=="__main__":
main()
下载后在content文件夹下会自动抓取所有图片。 (色影无忌的服务器没有做任何的屏蔽处理,所以脚本不能跑那么快,可以适当调用sleep函数,不要让服务器压力那么大)
已经下载好的图片:
github: https://github.com/Rockyzsu/fetchXitek (欢迎前来star) 查看全部
不多说,直接来代码:
#-*-coding=utf-8-*-
__author__ = 'rocky chen'
from bs4 import BeautifulSoup
import urllib2,sys,StringIO,gzip,time,random,re,urllib,os
reload(sys)
sys.setdefaultencoding('utf-8')
class Xitek():
def __init__(self):
self.url="http://photo.xitek.com/"
user_agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
self.headers={"User-Agent":user_agent}
self.last_page=self.__get_last_page()
def __get_last_page(self):
html=self.__getContentAuto(self.url)
bs=BeautifulSoup(html,"html.parser")
page=bs.find_all('a',class_="blast")
last_page=page[0]['href'].split('/')[-1]
return int(last_page)
def __getContentAuto(self,url):
req=urllib2.Request(url,headers=self.headers)
resp=urllib2.urlopen(req)
#time.sleep(2*random.random())
content=resp.read()
info=resp.info().get("Content-Encoding")
if info==None:
return content
else:
t=StringIO.StringIO(content)
gziper=gzip.GzipFile(fileobj=t)
html = gziper.read()
return html
#def __getFileName(self,stream):
def __download(self,url):
p=re.compile(r'href="(/photoid/\d+)"')
#html=self.__getContentNoZip(url)
html=self.__getContentAuto(url)
content = p.findall(html)
for i in content:
print i
photoid=self.__getContentAuto(self.url+i)
bs=BeautifulSoup(photoid,"html.parser")
final_link=bs.find('img',class_="mimg")['src']
print final_link
#pic_stream=self.__getContentAuto(final_link)
title=bs.title.string.strip()
filename = re.sub('[\/:*?"<>|]', '-', title)
filename=filename+'.jpg'
urllib.urlretrieve(final_link,filename)
#f=open(filename,'w')
#f.write(pic_stream)
#f.close()
#print html
#bs=BeautifulSoup(html,"html.parser")
#content=bs.find_all(p)
#for i in content:
# print i
'''
print bs.title
element_link=bs.find_all('div',class_="element")
print len(element_link)
k=1
for href in element_link:
#print type(href)
#print href.tag
'''
'''
if href.children[0]:
print href.children[0]
'''
'''
t=0
for i in href.children:
#if i.a:
if t==0:
#print k
if i['href']
print link
if p.findall(link):
full_path=self.url[0:len(self.url)-1]+link
sub_html=self.__getContent(full_path)
bs=BeautifulSoup(sub_html,"html.parser")
final_link=bs.find('img',class_="mimg")['src']
#time.sleep(2*random.random())
print final_link
#k=k+1
#print type(i)
#print i.tag
#if hasattr(i,"href"):
#print i['href']
#print i.tag
t=t+1
#print "*"
'''
'''
if href:
if href.children:
print href.children[0]
'''
#print "one element link"
def getPhoto(self):
start=0
#use style/0
photo_url="http://photo.xitek.com/style/0/p/"
for i in range(start,self.last_page+1):
url=photo_url+str(i)
print url
#time.sleep(1)
self.__download(url)
'''
url="http://photo.xitek.com/style/0/p/10"
self.__download(url)
'''
#url="http://photo.xitek.com/style/0/p/0"
#html=self.__getContent(url)
#url="http://photo.xitek.com/"
#html=self.__getContentNoZip(url)
#print html
#'''
def main():
sub_folder = os.path.join(os.getcwd(), "content")
if not os.path.exists(sub_folder):
os.mkdir(sub_folder)
os.chdir(sub_folder)
obj=Xitek()
obj.getPhoto()
if __name__=="__main__":
main()
下载后在content文件夹下会自动抓取所有图片。 (色影无忌的服务器没有做任何的屏蔽处理,所以脚本不能跑那么快,可以适当调用sleep函数,不要让服务器压力那么大)
已经下载好的图片:
github: https://github.com/Rockyzsu/fetchXitek (欢迎前来star)
python获取列表中的最大值
python • 李魔佛 发表了文章 • 0 个评论 • 5706 次浏览 • 2016-06-29 16:35
list=[1,2,3,5,4,6,434,2323,333,99999]
print "max of list is ",
print max(list)
输出 99999 查看全部
list=[1,2,3,5,4,6,434,2323,333,99999]
print "max of list is ",
print max(list)
输出 99999
换手率 你未必懂的地方
股票 • 李魔佛 发表了文章 • 0 个评论 • 3321 次浏览 • 2016-06-24 18:21
很多人都知道换手率代表一个股票的活跃程度,不过里面还是有一些不为人知的地方。
比如: 近期的新股 中国核建
换手率为0.52%, 看起来很低吧。
可是很多人忽略了一个地方,换手率的公式= 当天成交股票股数/流通股本, 而对于很多新股来说,会有很大部分的禁售股, 中国核建总股本26亿,而流通股才5亿多,超过20亿股本是暂时无法流通的,所以目前在市场上活跃的股本才5亿, 也就是真正的换手率 为 = 当日成交股票股数/流通股本 , 对于中国核建来说,它的实际换手率为 = 2.73万*100/5.25亿 * 100% = 0.52%
而对于新股来说,一般如果换手超过2%,下一天很可能就会开板。对于次新股来说,还可以接到1~2个涨停板左右。
查看全部
很多人都知道换手率代表一个股票的活跃程度,不过里面还是有一些不为人知的地方。
比如: 近期的新股 中国核建
换手率为0.52%, 看起来很低吧。
可是很多人忽略了一个地方,换手率的公式= 当天成交股票股数/流通股本, 而对于很多新股来说,会有很大部分的禁售股, 中国核建总股本26亿,而流通股才5亿多,超过20亿股本是暂时无法流通的,所以目前在市场上活跃的股本才5亿, 也就是真正的换手率 为 = 当日成交股票股数/流通股本 , 对于中国核建来说,它的实际换手率为 = 2.73万*100/5.25亿 * 100% = 0.52%
而对于新股来说,一般如果换手超过2%,下一天很可能就会开板。对于次新股来说,还可以接到1~2个涨停板左右。
同花顺好像很想英国脱欧呀!!!
股票 • 李魔佛 发表了文章 • 0 个评论 • 3776 次浏览 • 2016-06-24 08:34
自己去BBC官网看看? 就拿一个地区数据来说话,要炒股赢钱,千万不能看一个扭曲事实的同花顺。
黄色的remain是留,蓝色的leave是离。
炒股最忌讳的就是用他人的二手过滤过的数据,尤其是用户群巨大的网站社区。 一个有偏颇的数据会引起巨大的涟漪。
查看全部
物联网 标的个股 --延华智能
股票 • 李魔佛 发表了文章 • 0 个评论 • 3752 次浏览 • 2016-06-23 23:33
智慧城市, 建筑节能, 智能医疗,养老概念
今天放量进入龙虎榜单。 涨停原因就是物联网题材的兴起。
先看看延华智能的龙虎榜
买一到买四清一色的机构席位。
而卖出的四个都是游资。
关键还是看看卖出买入占比, 前5买入占了30%,而卖出前5才占17%,差的太多了。
说明买入的是超大单,集中度高; 而卖出的是游资掺杂着很多的散户。而且不少实在涨停板上卖出的,从分价表上可以看出来。
所以上面的4个机构很可能是家机构,明天冲高不能追加。 要看最高后回落情况,如果承接的好,那么说明后面还有肉。 不然冲高就应该减仓。
查看全部




