title: Validate urls using Python and Selenium
body: <p>i want to do some basic url validation,and if url is invalid,request should not be proceed unless user have entered a valid one.
  <strong>Update</strong>: To be more clear I do not want the browser to be opened and image counter scipt to be runed unless the entered Url is valid.</p>
  
  <pre><code>import time 
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  
  user_url = input('Please enter a valid url:')
  driver = webdriver.Chrome('/home/m/Desktop/chromedriver')
  driver.get(user_url)
  HEADERS = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36', 'accept': '*/*'}
  
  time.sleep(8)
  
  imagecounter = driver.find_elements_by_css_selector('img')
  
  print('Number of HTML image tags:')
  print(len(imagecounter))
  </code></pre>
  
  <p>Could you please modify the code and explain what is happening?
   I have tried with some libraries, but i think because of my poor coding skills there was no luck.</p>