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]
评论列表
文章目录