I parse the link with the following code:
m = re.search('http\://([^/]*)/?.*', url) host = m.group(1) But if you insert a link with https, an error will occur:
AttributeError: 'NoneType' object has no attribute 'group' Is it possible to somehow rewrite the code so that the .search function can accept both http and https at the same time?
re.search('http[s]?\://([^/]*)/?.*', url), but it's better to do this with special modules ... - MaxUm = re.search(...),if m:host=m.group(1), otherwise such errors cannot be avoided. Can a single character be optional with a quantifier?. - Wiktor Stribiżew pm