This commit is contained in:
@@ -13,17 +13,23 @@ async def visit_url_service(decoded_url):
|
||||
if not response:
|
||||
print(f"Warning: No response object returned for {decoded_url}")
|
||||
|
||||
cookie_buttons = [
|
||||
'Accept all',
|
||||
'Accepteer',
|
||||
'Accepteren',
|
||||
'Accept'
|
||||
]
|
||||
|
||||
try:
|
||||
# if page has text "Accept all" or "Accepteer" or "Accept" click it
|
||||
if await page.evaluate('''() => {
|
||||
return document.querySelector('text=Accept all') ||
|
||||
document.querySelector('text=Accepteer') ||
|
||||
document.querySelector('text=Accept');
|
||||
}'''):
|
||||
await page.click('text=Accept all')
|
||||
await page.click('text=Accepteer')
|
||||
await page.click('text=Accept')
|
||||
except:
|
||||
for button in cookie_buttons:
|
||||
element = await page.query_selector(f'text="{button}"')
|
||||
if element:
|
||||
await element.click()
|
||||
print(f"{button} button found and clicked")
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during cookie acceptance: {e}")
|
||||
print("No cookies to accept")
|
||||
|
||||
# Get page content
|
||||
|
||||
Reference in New Issue
Block a user