auto_exchange.py 文件源码

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

项目:gooderp_addons 作者: osbzr 项目源码 文件源码
def get_web_exchange(self, line_date):
        '''??????????????'''
        http = httplib2.Http()
        if self.name not in currency_code:
            raise UserError(u'?????????(%s)????' % self.currency_id.name)
        url = 'http://srh.bankofchina.com/search/whpj/search.jsp'
        body = {
            'erectDate': line_date,
            'nothing': line_date,
            'pjname': currency_code[self.name]
        }
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.6 Safari/537.36',
            'Content-type': 'application/x-www-form-urlencoded'
        }
        try:
            response, content = http.request(
                url, 'POST', headers=headers, body=urllib.urlencode(body))
            result = etree.HTML(content.decode('utf8')).xpath(
                '//table[@cellpadding="0"]/tr[4]/td/text()')
        except httplib2.HttpLib2Error:
            raise UserError(u'??????(%s)???????qq?2201864?' % url)
        return result[5]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号