2020-03-19 20:04:57 +00:00
|
|
|
const getAudio = async word => {
|
2020-03-20 15:19:09 +00:00
|
|
|
const site = await fetch(`https://www.lexico.com/definition/${word}`, {
|
2020-03-13 20:45:31 +00:00
|
|
|
method: 'GET',
|
|
|
|
headers: {'Content-Type': 'text/html'},
|
|
|
|
});
|
|
|
|
const html = await site.text();
|
|
|
|
const getSrc = new RegExp('<audio.+?src="(.+?)".+?/?>');
|
|
|
|
const src = html.match(getSrc)[1];
|
|
|
|
|
|
|
|
return src;
|
|
|
|
};
|
|
|
|
export default getAudio;
|