Add: utils function to extract urls with LinkifyIt lib
This commit is contained in:
parent
14acfbe73b
commit
9365b9613b
1 changed files with 14 additions and 0 deletions
14
backend/utils/strings.py
Normal file
14
backend/utils/strings.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from linkify_it import LinkifyIt
|
||||
from linkify_it.tlds import TLDS
|
||||
|
||||
|
||||
def extract_urls(text: str, deepweb_tls: bool = False, fuzzy_ip: bool = False):
|
||||
linkify = LinkifyIt()
|
||||
linkify.tlds(TLDS)
|
||||
if deepweb_tls:
|
||||
linkify.tlds("i2p", True)
|
||||
linkify.tlds("onion", True)
|
||||
if fuzzy_ip:
|
||||
linkify.set({"fuzzy_ip": True})
|
||||
|
||||
return linkify.match(text)
|
Loading…
Add table
Add a link
Reference in a new issue