Skip to content

Commit

Permalink
Merge branch 'feat/fech-available-movies' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NemesisX1 committed Oct 23, 2023
2 parents dcaf0a6 + f741a19 commit 6395b83
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/services/scapping/scrapping.servive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ScrappingService implements BaseService {

const browser = await puppeteer.launch({ headless: 'new', args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();

try {

await page.goto(
Expand All @@ -42,26 +42,28 @@ export default class ScrappingService implements BaseService {
const htmlRoot = parse(await page.content());

const aMovieList = htmlRoot.querySelectorAll('section.homepage-affiche > div.wrapper > div.homepage-affiche-list > a.homepage-affiche-list-movie');

aMovieList.forEach((e) => {
const url = e.rawAttributes.href ?? '/';
if (e.rawAttributes.href) {
const url = e.rawAttributes.href;

const title = e.querySelector('article > h1')?.textContent!;
const imageUrl = e.querySelector('article > figure > img')?.rawAttributes.src ?? null;
const title = e.querySelector('article > h1')?.textContent!;
const imageUrl = e.querySelector('article > figure > img')?.rawAttributes.src ?? null;

result.push({
title: title,
img: imageUrl!,
url: url,
slug: url.split('/').filter(e => e != '').pop()!,
})
result.push({
title: title,
img: imageUrl!,
url: url,
slug: url.split('/').filter(e => e != '').pop()!,
})
}
})

await browser.close();

return result;
}

/**
* getTheatersNames
*/
Expand Down

0 comments on commit 6395b83

Please sign in to comment.