Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output 'None'
#3
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 --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.
Reply


Messages In This Thread
Output 'None' - by liketocode - May-21-2023, 11:27 AM
RE: Output 'None' - by snippsat - May-21-2023, 01:12 PM
RE: Output 'None' - by snippsat - May-26-2023, 07:13 PM
RE: Output 'None' - by Gaurav_Kumar - Jul-20-2023, 11:21 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020