Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- text = input()
- title_pattern = r"<title>(.+)</title>"
- title_match = re.search(title_pattern, text)
- title = title_match.group(1)
- body_pattern = r"<body>(.+)</body>"
- body_match = re.search(body_pattern, text)
- body = body_match.group(1)
- content_pattern = r"(^|>)(.[^<>]*)(<|$)"
- content_match = re.findall(content_pattern, body)
- content = [x[1] for x in content_match]
- content = "".join(content)
- content = re.sub(r"\\n", '', content)
- print(f"Title: {title}")
- print(f"Content: {content}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement