This commit is contained in:
Ken Yasue
2025-03-24 06:47:48 +01:00
2 changed files with 60 additions and 13 deletions

View File

@ -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++) {