Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if your credentials fail #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/profile/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ module.exports = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGet
logger.info(`starting scraping url: ${url}`)

const page = await openPage({ browser, cookies, url, puppeteerAuthenticate })
let authIssues;
page.on('request', req => {
const url = req.url();
if (url.includes('authwall') || url.includes('checkpoint')) {
authIssues = url
}
})

const profilePageIndicatorSelector = '.pv-profile-section'
await page.waitFor(profilePageIndicatorSelector, { timeout: 5000 })
.catch(() => {
Expand All @@ -21,6 +29,11 @@ module.exports = async (browser, cookies, url, waitTimeToScrapMs = 500, hasToGet
logger.warn('profile selector was not found')
})

// Check for auth issues
if (authIssues) {
throw new Error(`Credentials issue! You have been redirected to ${authIssues}`)
}

logger.info('scrolling page to the bottom')
await scrollToPageBottom(page)

Expand Down