Skip to content

Commit

Permalink
fix: add browser instance limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sosweetham committed May 5, 2024
1 parent 206694e commit a8937fc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/libs/guilded-scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export let browserInstances: Browser[] = []
export const guildedUserProfileScrape: (id: string, getElement: 'avatar' | 'banner') => Promise<Blob|Error> = async (id: string, getElement: 'avatar' | 'banner') => {
try {
const getClass = getElement === 'avatar' ? '.UserProfilePictureControl-picture' : '.UserProfileBackground-image'
if (browserInstances.length > 5) {
throw new Error('Too many requests')
}
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
Expand Down Expand Up @@ -36,6 +39,9 @@ export const guildedUserProfileScrape: (id: string, getElement: 'avatar' | 'bann
export const guildedServerProfileScrape: (id: string, getElement: 'icon' | 'banner') => Promise<Blob | Error> = async (id, getElement) => {
try {
const getClass = getElement === 'icon' ? '.TeamPlaqueV2-profile-pic' : '.TeamOverviewBanner-banner.TeamPageBanner-overview-banner'
if (browserInstances.length > 5) {
throw new Error('Too many requests')
}
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
Expand Down

0 comments on commit a8937fc

Please sign in to comment.