I am trying to scrape a news webside, but it is not possible to accept the "accept cookies" popup by using the click()
method. I can see the button in my HTML code in my browser, but when I use getPageSource()
method the code for the button is not included.
Here my code block
public class Webscraping {
public static void main(String[] args) throws Exception{
System.setProperty("webdriver.chrome.driver","C:\\Users\\Marvin\\Desktop\\Webscraping\\chromedriver.exe");
//Pop Up blocken
//ChromeOptions options = new ChromeOptions();
//options.addArguments("disable-popup-blocking");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
String url = "https://www.focus.de/";
driver.get(url);
Thread.sleep(5000);
//HTML Code print
System.out.println(driver.getPageSource());
}
}