Gone do the task as a quick test in Selenium,because i wonder about Headless is Going Away!
So a little lie,not going away but change to
So for someone not use Selenium before,so is
So a little lie,not going away but change to
--headless=new
.So for someone not use Selenium before,so is
headless
a way to not load the browser,just get the result as eg parse with BS.from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import time #--| Setup options = Options() options.add_argument("--headless=new") ser = Service(r"C:\cmder\bin\chromedriver.exe") browser = webdriver.Chrome(service=ser, options=options) #--| Parse or automation url = 'https://freemeteo.com.hr/vrijeme/zagreb/trenutno-vrijeme/mjesto/?gid=3186886&language=croatian&country=croatia' browser.get(url) time.sleep(2) weather_info = browser.find_element(By.CSS_SELECTOR, '#current-weather > div.last-renew-info') temp = browser.find_element(By.CSS_SELECTOR, '#current-weather > div.last-renew-info > div.temp') print(weather_info.text) print('\N{snake}' * 5) print(temp.text)
Output:Zagreb
20°C Vedro vrijeme Vjetar:
7 Km/h
Relativna vlažnost: 60% | Vidljivost: > 10000m | Tlak: 1019,0mb
🐍🐍🐍🐍🐍
20°C
So see that the new --headless=new
mode works.