new way of scraping
This commit is contained in:
@ -23,6 +23,8 @@ export class WebDriverUtils {
|
||||
let scrollCounter = 0;
|
||||
|
||||
while (Date.now() < endTime) {
|
||||
|
||||
/*
|
||||
try {
|
||||
if (driver) {
|
||||
await driver.executeScript(`
|
||||
@ -34,6 +36,7 @@ export class WebDriverUtils {
|
||||
} catch (error) {
|
||||
console.warn('Scroll failed:', error);
|
||||
}
|
||||
*/
|
||||
|
||||
// Wait a little between scrolls
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
@ -105,7 +108,7 @@ export async function disableCookiesInChrome(): Promise<WebDriver | null> {
|
||||
|
||||
}
|
||||
|
||||
export async function useChrome(): Promise<WebDriver | null> {
|
||||
export async function useChrome(initialUrl: string = "https://www.tripadvisor.com/"): Promise<WebDriver | null> {
|
||||
// Set Chrome options
|
||||
const options = new chrome.Options();
|
||||
|
||||
@ -127,7 +130,7 @@ export async function useChrome(): Promise<WebDriver | null> {
|
||||
.setChromeOptions(options)
|
||||
.build();
|
||||
|
||||
await driver.get('https://www.tripadvisor.com/');
|
||||
await driver.get(initialUrl);
|
||||
|
||||
console.log('Chrome launched with cookies disabled.');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user