MCPcopy
hub / github.com/scrapy/scrapy / url_is_from_any_domain

Function url_is_from_any_domain

scrapy/utils/url.py:22–27  ·  view source on GitHub ↗

Return True if the url belongs to any of the given domains

(url: UrlT, domains: Iterable[str])

Source from the content-addressed store, hash-verified

20
21
22def url_is_from_any_domain(url: UrlT, domains: Iterable[str]) -> bool:
23 """Return True if the url belongs to any of the given domains"""
24 host = parse_url(url).netloc.lower()
25 if not host:
26 return False
27 return any((host == d) or (host.endswith(f".{d}")) for d in map(str.lower, domains))
28
29
30def _spider_domains(spider: type[Spider]) -> Iterable[str]:

Callers 5

_link_allowedMethod · 0.90
matchesMethod · 0.90
process_requestMethod · 0.90
url_is_from_spiderFunction · 0.85

Calls

no outgoing calls

Tested by 1