import re def extract_id(url): match = re.search("(?<=\/)[\d]+(?=[?])", url) if (match == None): return -1 else: id = match.group() return id def count_comments(html): matches = re.findall("\"date\"", html) return len(matches) def clear_comment(comment): replacement = ['\r', '\n', ','] for word in replacement: comment = comment.replace(word, "") return comment