viligen

html_parser

Nov 20th, 2021
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import re
  2.  
  3. line = input()
  4.  
  5. text = line.replace('\\n', "")
  6. pattern_title = r"<title>(.*)</title>"
  7. pattern_content = r"\>(.*?\.?)\<"
  8. title = re.search(pattern_title, text).group(1)
  9. print(f"Title: {title}")
  10.  
  11. matches = re.findall(pattern_content, text)
  12. print("Content: ", end="")
  13. for match in matches:
  14.     if match and match != title:
  15.         print(match, end="")
  16.  
Advertisement
Add Comment
Please, Sign In to add comment