- Created core modules: `ai-analyzer`, `core-parser`, and `job-search-parser`. - Implemented LinkedIn and job search parsers with integrated AI analysis. - Added CLI tools for AI analysis and job parsing. - Included comprehensive README files for each module detailing usage and features. - Established a `.gitignore` file to exclude unnecessary files. - Introduced sample data for testing and demonstration purposes. - Set up package.json files for dependency management across modules. - Implemented logging and error handling utilities for better debugging and user feedback.
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
const playwright = require('playwright');
|
|
const AuthManager = require('./auth-manager');
|
|
const NavigationManager = require('./navigation');
|
|
|
|
class CoreParser {
|
|
constructor(config = {}) {
|
|
this.config = {
|
|
headless: true,
|
|
timeout: 60000, // Increased default timeout
|
|
...config
|
|
};
|
|
this.browser = null;
|
|
this.context = null;
|
|
this.pages = {};
|
|
this.authManager = new AuthManager(this);
|
|
this.navigationManager = new NavigationManager(this);
|
|
}
|
|
|
|
async init() {
|
|
this.browser = await playwright.chromium.launch({
|
|
headless: this.config.headless
|
|
});
|
|
this.context = await this.browser.newContext();
|
|
}
|
|
|
|
async createPage(id) {
|
|
if (!this.browser) await this.init();
|
|
const page = await this.context.newPage();
|
|
this.pages[id] = page;
|
|
return page;
|
|
}
|
|
|
|
getPage(id) {
|
|
return this.pages[id];
|
|
}
|
|
|
|
async authenticate(site, credentials, pageId) {
|
|
return this.authManager.authenticate(site, credentials, pageId);
|
|
}
|
|
|
|
async navigateTo(url, options = {}) {
|
|
const {
|
|
pageId = "default",
|
|
waitUntil = "networkidle", // Changed default to networkidle
|
|
retries = 1,
|
|
retryDelay = 2000,
|
|
timeout = this.config.timeout,
|
|
} = options;
|
|
|
|
return this.navigationManager.navigateTo(url, options);
|
|
}
|
|
|
|
async cleanup() {
|
|
if (this.browser) {
|
|
await this.browser.close();
|
|
this.browser = null;
|
|
this.context = null;
|
|
this.pages = {};
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = CoreParser;
|
|
|