lavague-ai / LaVague

Large Action Model framework to develop AI Web Agents
https://docs.lavague.ai/en/latest/
Apache License 2.0
5.35k stars 483 forks source link

Allow Customization of User-Agent #380

Closed adeprez closed 2 months ago

adeprez commented 3 months ago

Some websites block page loads when they detect a headless user-agent. This can prevent LaVague from functioning correctly when interacting with these sites. To address this, we need to allow customization of the user-agent string. Additionally, we should provide a default user-agent that mimics a standard browser to avoid detection.

Required for Selenium and Playwright drivers. Not needed for Chrome extension driver.

How to reproduce:

from lavague.drivers.selenium import SeleniumDriver
from selenium.webdriver.common.by import By
from time import sleep

selenium_driver = SeleniumDriver(headless=False)
driver = selenium_driver.driver
driver.get("https://www.opentable.com/r/trace-paris")
sleep(6)
elem = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/main/div")
print(elem.get_dom_attribute("class"))