mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fixed improper domain name extraction + added dependency
This commit is contained in:
parent
1e970337a8
commit
011f23c35a
|
@ -5,4 +5,5 @@ nest-asyncio >= 1.4.0
|
|||
irc >= 19.0.1
|
||||
beautifulsoup4>=4.9.3
|
||||
asyncpg>=0.22.0
|
||||
requests>=2.31.0
|
||||
requests>=2.31.0
|
||||
tldextract>=5.1.2
|
|
@ -11,6 +11,7 @@ from src.irc_feed import AioIRCCat
|
|||
from io import StringIO
|
||||
from contextlib import redirect_stdout
|
||||
from src.wiki import Wiki
|
||||
import tldextract
|
||||
|
||||
logger = logging.getLogger("rcgcdb.domain_manager")
|
||||
|
||||
|
@ -102,8 +103,7 @@ class DomainManager:
|
|||
@staticmethod
|
||||
def get_domain(url: str) -> str:
|
||||
"""Returns a domain for given URL (for example fandom.com, wikipedia.org)"""
|
||||
parsed_url = urlparse(url)
|
||||
return ".".join(urlunparse((*parsed_url[0:2], "", "", "", "")).split(".")[-2:])
|
||||
return tldextract.extract(url).registered_domain
|
||||
|
||||
def check_for_domain(self, domain: str):
|
||||
return domain in self.domains
|
||||
|
|
Loading…
Reference in a new issue