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