Update server.js
Browse files
server.js
CHANGED
|
@@ -10,7 +10,9 @@ const PORT = 7860;
|
|
| 10 |
async function transcript(url) {
|
| 11 |
const response = await axios.post( 'https://youtubetotranscript.com/transcript', new URLSearchParams({ youtube_url: url }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } );
|
| 12 |
const html = response.data;
|
| 13 |
-
const $ = cheerio.load(html);
|
|
|
|
|
|
|
| 14 |
};
|
| 15 |
|
| 16 |
app.get('/transcript', async (req, res) => {
|
|
|
|
| 10 |
async function transcript(url) {
|
| 11 |
const response = await axios.post( 'https://youtubetotranscript.com/transcript', new URLSearchParams({ youtube_url: url }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } );
|
| 12 |
const html = response.data;
|
| 13 |
+
const $ = cheerio.load(html);
|
| 14 |
+
const texts = $('.transcript-segment').map((i, el) => $(el).text().trim()).get();
|
| 15 |
+
return texts;
|
| 16 |
};
|
| 17 |
|
| 18 |
app.get('/transcript', async (req, res) => {
|