Skip to content

Commit

Permalink
added parser of site quote
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulNaturalist committed Nov 19, 2024
1 parent b34243c commit bd305cb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions backend/parser/quote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
const quoteArray = ['https://mybook.ru/author/mihail-bulgakov/master-i-margarita-1/citations/']
for (const quote of quoteArray) {
await page.goto(quote);
const texts = await page.evaluate(() => {
const articles = document.querySelectorAll('article');
return Array.from(articles).map(article => article.textContent.trim());
});

console.log(texts);
}
await browser.close();
})();

0 comments on commit bd305cb

Please sign in to comment.