refactor
This commit is contained in:
15
src/index.ts
15
src/index.ts
@ -9,7 +9,7 @@ import chrome, { ServiceBuilder } from 'selenium-webdriver/chrome';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { getCities } from './lib/cities';
|
||||
import { WebDriverUtils, saveContactInfoToCSV } from './lib/utils';
|
||||
import { WebDriverUtils, saveContactInfoToCSV, useExistingChrome, disableCookiesInChrome } from './lib/utils';
|
||||
import * as UIActions from './lib/UIActions';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
@ -23,17 +23,8 @@ async function visitCityPages(): Promise<void> {
|
||||
|
||||
console.log('Connecting to existing Chrome browser...');
|
||||
|
||||
// Connect to an existing Chrome browser running in debug mode on port 9222
|
||||
const options = new chrome.Options();
|
||||
|
||||
// Set the debugger address to connect to the existing Chrome instance
|
||||
options.debuggerAddress('localhost:9222');
|
||||
|
||||
// Create WebDriver instance that connects to the existing browser
|
||||
const driver: WebDriver = await new Builder()
|
||||
.forBrowser('chrome')
|
||||
.setChromeOptions(options)
|
||||
.build();
|
||||
const driver = await useExistingChrome();
|
||||
if (!driver) return;
|
||||
|
||||
// Visit each city's TripAdvisor page
|
||||
for (let i = 0; i < cities.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user