我很新的python。我试图解析一个URL文件只留下域名。 我的日志文件中的一些网址以http://开头,有些以www.some开头。 这是我的代码的一部分剥去http://部分。我需要添加什么来查找http和www。并删除? line = re.findall(r'(https?://\S+)', line)
目前,当我运行的代码只有http://被剥离。如果我将代码更改为以下内容: lin
我: from urlparse import urlparse
s = "http://google.com" + "\n" # this line is read from file, when I loop over file's lines
urlparse(s)
ParseResult(scheme='http', netloc='google.com\n', path='', p
有没有一个标准功能来检查IRI,来检查URL显然,我可以使用: parts = urlparse.urlsplit(url)
if not parts.scheme or not parts.netloc:
'''apparently not an url'''
我尝试了上面的URL包含Unicode字符: import urlparse
url = "http://f