def facebook_validation_function(url):
try:
url_parts = _get_url_parts(url)
# check if acceptable domain
domain = url_parts[1]
if not (domain == 'facebook.com' or domain.endswith('.facebook.com')):
return None
path = _get_initial_path(url_parts)
# old style numeric profiles
if path == "profile.php": # ex. https://www.facebook.com/profile.php?id=100010279981469
path = parse_qs(url_parts[3]).get('id')[0]
if path == 'people': # ex. https://www.facebook.com/people/John-Doe/100013326345115
path = url_parts[2].strip('/').split('/')[2].lower()
# TODO: validate against allowed username characteristics
# https://github.com/project-callisto/callisto-core/issues/181
if not path or path == "" or path.endswith(
'.php') or path in generic_fb_urls:
return None
else:
return path
except ValidationError:
return None
评论列表
文章目录