newsevent.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:stock 作者: datablood 项目源码 文件源码
def get_notices(code=None, date=None):
    '''
    ??????
    Parameters
    --------
        code:????
        date:??????

    Return
    --------
        DataFrame??????
        title:????
        type:????
        date:????
        url:????URL
    '''
    if code is None:
        return None
    symbol = 'sh' + code if code[:1] == '6' else 'sz' + code
    url = nv.NOTICE_INFO_URL%(ct.P_TYPE['http'], ct.DOMAINS['vsf'],
                              ct.PAGES['ntinfo'], symbol)
    url = url if date is None else '%s&gg_date=%s'%(url, date)
    html = lxml.html.parse(url)
    res = html.xpath('//table[@class=\"body_table\"]/tbody/tr')
    data = []
    for td in res:
        title = td.xpath('th/a/text()')[0]
        type = td.xpath('td[1]/text()')[0]
        date = td.xpath('td[2]/text()')[0]
        url = '%s%s%s'%(ct.P_TYPE['http'], ct.DOMAINS['vsf'], td.xpath('th/a/@href')[0])
        data.append([title, type, date, url])
    df = pd.DataFrame(data, columns=nv.NOTICE_INFO_CLS)
    return df
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号