Add: util fuction to check if string is html

This commit is contained in:
Aroy-Art 2024-06-04 20:36:30 +02:00
parent 4af5fdf9e0
commit ef1361ec39
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -1,6 +1,8 @@
import math, re
from bs4 import BeautifulSoup
def get_urls(string:str = None) -> list:
"""
Extracts URLs from a given string using regular expressions.
@ -35,3 +37,17 @@ def convert_size(size_bytes: int) -> str:
p = math.pow(1024, i)
s = round(size_bytes / p, 2)
return f"{s} {size_name[i]}"
def is_string_html(string: str) -> bool:
'''
Check if string is HTML
Parameters:
string (str): The string to be checked
Returns:
bool: True if string is HTML, False otherwise
'''
return bool(BeautifulSoup(string, "html.parser").find())