Code:
async function watchAnime(episode_id) {
res = await axios.get(`https://www1.gogoanime.cm/${episode_id}`)
const body = await res.data;
$ = cheerio.load(body)
src=$('div.play-video > iframe').attr('src')
iframe_result = src
return await (iframe_result)
}
Output :
"//gogoplay1.com/streaming.php?id=MTU1MzEy&title=B: The Beginning Succession (Dub) Episode 6"
Image : https://i.stack.imgur.com/yeM0C.png
So its there a way to remove the quotation marks from the output URL??
CodePudding user response:
To get a copy of a string str
without its first and last character :
const newString = str.substring(1, str.length-1)
So :
const str = `"foo"`
console.log(str.substring(1, str.length-1)) // output foo
CodePudding user response:
You may use .replace()
src.replace(/['"] /g, '')
So in your case
async function watchAnime(episode_id) {
res = await axios.get(`https://www1.gogoanime.cm/${episode_id}`)
const body = await res.data;
$ = cheerio.load(body)
let src = $('div.play-video > iframe').attr('src')
let iframe_result = src.replace(/['"] /g, '')
return await (iframe_result)
}
CodePudding user response:
You can try use .replace function like this :
const string = `i am' abc `;
console.log(string.replace("'", ''))
console : i am abc
you can read more about is here