Skip to content

Commit

Permalink
fix(scraper): fix wait for selectors
Browse files Browse the repository at this point in the history
Signed-off-by: euberdeveloper <euberdeveloper@gmail.com>
  • Loading branch information
euberdeveloper committed Feb 5, 2022
1 parent 67d2f01 commit 726098b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbb-video-scraper",
"version": "1.0.1",
"version": "1.0.2",
"description": "This is a scraper written in Node.js and using Puppeteer that gets the videos served by BBB services",
"main": "bundled/index.js",
"types": "bundled/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions source/utils/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ export class BBBVideoScraper {
await page.goto(url, { waitUntil: 'networkidle0' });

if (scrapingOptions.duration === null) {
logger.debug('Waiting for selector of video duration');
await page.waitForSelector('.vjs-remaining-time-display');

logger.debug('Getting the total time of the video');
const durationText = await page.$eval('.vjs-remaining-time-display', el => {
return el.innerHTML;
});
scrapingOptions.duration = this.handleDurationText(durationText);
}

logger.debug('Waiting for selector of play button');
await page.waitForSelector('.vjs-big-play-button');

logger.debug('Clicking play on the video');
await page.click('.vjs-big-play-button');

Expand Down

0 comments on commit 726098b

Please sign in to comment.