def get_gdp_quarter():
 rdint = vs.random()
 request = Request((vs.MACRO_URL % (vs.P_TYPE['http'], vs.DOMAINS['sina'], rdint, vs.MACRO_TYPE[0], 1, 250, rdint)))
 text = urlopen(request, timeout=10).read()
 text = (text.decode('gbk') if ct.PY3 else text)
 regSym = re.compile('\\,count:(.*?)\\}')
 datastr = regSym.findall(text)
 datastr = datastr[0]
 datastr = datastr.split('data:')[1]
 datastr = datastr.replace('"', '').replace('null', '0')
 js = json.loads(datastr)
 df = pd.DataFrame(js, columns=vs.GDP_QUARTER_COLS)
 df['quarter'] = df['quarter'].astype(object)
 df[(df == 0)] = np.NaN
 return df

def get_gdp_quarter ( ) : rdint = vs . random ( ) request = Request ( ( vs . MACRO_URL % ( vs . P_TYPE [ 'http' ] , vs . DOMAINS [ 'sina' ] , rdint , vs . MACRO_TYPE [ 0 ] , 1 , 250 , rdint ) ) ) text = urlopen ( request , timeout = 10 ) . read ( ) text = ( text . decode ( 'gbk' ) if ct . PY3 else text ) regSym = re . compile ( '\\,count:(.*?)\\}' ) datastr = regSym . findall ( text ) datastr = datastr [ 0 ] datastr = datastr . split ( 'data:' ) [ 1 ] datastr = datastr . replace ( '"' , '' ) . replace ( 'null' , '0' ) js = json . loads ( datastr ) df = pd . DataFrame ( js , columns = vs . GDP_QUARTER_COLS ) df [ 'quarter' ] = df [ 'quarter' ] . astype ( object ) df [ ( df == 0 ) ] = np . NaN return df
return dataframe quarter :季度 gdp :国内生产总值 gdp_yoy :国内生产总值同比增长(%) pi :第一产业增加值 pi_yoy:第一产业增加值同比增长(%) si :第二产业增加值 si_yoy :第二产业增加值同比增长(%) ti :第三产业增加值 ti_yoy :第三产业增加值同比增长(%) .