title: unoptional protocol in entered link - py regex | requests
body: <p>Problem is:
  check if entered link is valid, <strong>optionally</strong> that link could be entered both as <a href="https://stackoverflow.com/">https://stackoverflow.com/</a> and stackoverflow.com.</p>
  <p>I tried to solve it as</p>
  <pre><code>input_url = str(input(&quot;Enter url: &quot;)
  result = re.findall(r'(http[s]?://)?\S+', input_url)
  </code></pre>
  <p>returns error - <code>Invalid URL '': No schema supplied. Perhaps you meant http://?</code></p>
  <p>no <code>urllib</code> or something else, it has to be only regex</p>
  <p>full code:</p>
  <pre><code>import re, requests
  from collections import Counter
  from prettytable import PrettyTable
  
  url_input = str(input(&quot;Enter url: &quot;))
  
  url_checked = re.findall(r'(http[s]?://)?\S+', url_input)[0] # берем первый элемент
  
  response = requests.get(str(url_checked)) # запрос на введенную ссылку
  
  result = re.findall( r&quot;\&quot;(?:http[s]?://)?([^:/\s\&quot;]+)/?[^\&quot;]*\&quot;&quot;, response.text) # фильтрация ссылок
  
  result.sort() # sorting by alphabet 
  
  # link - https://stackoverflow.com/
  
  pt = PrettyTable(field_names = [&quot;word&quot;, &quot;counter&quot;])
  pt.add_rows(list(Counter(result).most_common()))
  print(pt)
  </code></pre>