def get_city_yyb(self):
url = "http://data.eastmoney.com/stock/yybcx.html"
_data = self.sGet(url)
_urls = self.sMatch('href="/Stock/lhb/city/', '\.html"', _data, 0)
for x in xrange(0, len(_urls)):
#_urls[x] = 440000
detail = "http://data.eastmoney.com/DataCenter_V3/stock2016/yybSearch.ashx?pagesize=1000&page=1&js=var+fguIHta¶m=&sortRule=-1&sortType=UpCount&city=%s&typeCode=2&gpfw=0&code=%s&rt=24462162" % (_urls[x], _urls[x])
a = self.sGet(detail)
a = a.replace("var fguIHta=", "")
re = json.loads(a)
for k in range(0, len(re['data'])):
_tmp = re['data'][k]
indata = {
'province': _tmp['Province'],
'codex': _tmp['SalesCode'],
'name': _tmp['SalesName'],
'SumActMoney': _tmp['SumActMoney'],
'SumActBMoney': _tmp['SumActBMoney'],
'SumActSMoney': _tmp['SumActSMoney'],
'UpCount': _tmp['UpCount'],
'BCount': _tmp['BCount'],
'SCount': _tmp['SCount']
}
print indata
_has = self.mysql.fetch_one("select * from s_lhb where codex=%s" % _tmp['SalesCode'])
_where = "codex=%s" % _tmp['SalesCode']
if _has is not None:
self.mysql.dbUpdate('s_lhb', indata, _where)
else:
indata['last_dateline'] = datetime.strftime(date.today(), "%Y%m%d")
self.mysql.dbInsert('s_lhb', indata)
评论列表
文章目录