Update youdao.py
修改 默认音标字段(PHON),由只抓取 美音,改为 既包含英音 也包含美音。 同时增加抓取 英音(BRE_PHON) 和美音(AME_PHON) 字段
This commit is contained in:
parent
f50f796efe
commit
8789cf5dda
@ -39,6 +39,8 @@ class Youdao(WebService):
|
|||||||
'&le={0}&q={1}').format(lang, self.quote_word)
|
'&le={0}&q={1}').format(lang, self.quote_word)
|
||||||
result ={
|
result ={
|
||||||
'phonetic': '',
|
'phonetic': '',
|
||||||
|
'us_phonetic': '',
|
||||||
|
'uk_phonetic': '',
|
||||||
'explains':'',
|
'explains':'',
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
@ -48,18 +50,24 @@ class Youdao(WebService):
|
|||||||
symbol, uk_symbol, us_symbol = doc.findtext(".//phonetic-symbol"), doc.findtext(
|
symbol, uk_symbol, us_symbol = doc.findtext(".//phonetic-symbol"), doc.findtext(
|
||||||
".//uk-phonetic-symbol"), doc.findtext(".//us-phonetic-symbol")
|
".//uk-phonetic-symbol"), doc.findtext(".//us-phonetic-symbol")
|
||||||
if uk_symbol and us_symbol:
|
if uk_symbol and us_symbol:
|
||||||
#phonetics = 'UK [%s] US [%s]' % (uk_symbol, us_symbol)
|
phonetics = 'UK [%s] US [%s]' % (uk_symbol, us_symbol)
|
||||||
phonetics = '/%s/' % (us_symbol)
|
us_phonetics = '/%s/' % us_symbol
|
||||||
|
uk_phonetics = '/%s/' % uk_symbol
|
||||||
|
#phonetics = '/%s/' % (us_symbol)
|
||||||
elif symbol:
|
elif symbol:
|
||||||
phonetics = '/%s/' % symbol
|
phonetics = '/%s/' % symbol
|
||||||
|
us_phonetics = ''
|
||||||
|
uk_phonetics = ''
|
||||||
else:
|
else:
|
||||||
phonetics = ''
|
phonetics = ''
|
||||||
|
us_phonetics = ''
|
||||||
|
uk_phonetics = ''
|
||||||
# fetch explanations
|
# fetch explanations
|
||||||
explains = '<br>'.join([node.text
|
explains = '<br>'.join([node.text
|
||||||
for node in doc.findall(
|
for node in doc.findall(
|
||||||
".//custom-translation/translation/content"
|
".//custom-translation/translation/content"
|
||||||
)])
|
)])
|
||||||
result.update({'phonetic': phonetics, 'explains': explains})
|
result.update({'phonetic': phonetics, 'us_phonetic': us_phonetics, 'uk_phonetic': uk_phonetics, 'explains': explains})
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return self.cache_this(result)
|
return self.cache_this(result)
|
||||||
@ -68,6 +76,14 @@ class Youdao(WebService):
|
|||||||
def fld_phonetic(self):
|
def fld_phonetic(self):
|
||||||
return self._get_field('phonetic')
|
return self._get_field('phonetic')
|
||||||
|
|
||||||
|
@export('AME_PHON')
|
||||||
|
def fld_phonetic_us(self):
|
||||||
|
return self._get_field('us_phonetic')
|
||||||
|
|
||||||
|
@export('BRE_PHON')
|
||||||
|
def fld_phonetic_uk(self):
|
||||||
|
return self._get_field('uk_phonetic')
|
||||||
|
|
||||||
@export([u'基本释义', u'Explanations'])
|
@export([u'基本释义', u'Explanations'])
|
||||||
def fld_explains(self):
|
def fld_explains(self):
|
||||||
return self._get_field('explains')
|
return self._get_field('explains')
|
||||||
@ -139,7 +155,7 @@ class Youdao(WebService):
|
|||||||
def fld_blng_sents_part(self):
|
def fld_blng_sents_part(self):
|
||||||
return self._get_singledict('blng_sents_part')
|
return self._get_singledict('blng_sents_part')
|
||||||
|
|
||||||
@export([u'原生例句', u'Native examples'])
|
@export([u'原生例句', u''])
|
||||||
def fld_media_sents_part(self):
|
def fld_media_sents_part(self):
|
||||||
return self._get_singledict('media_sents_part')
|
return self._get_singledict('media_sents_part')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user