MCPcopy Create free account
hub / github.com/apify/crawlee-python / is_allowed

Method is_allowed

src/crawlee/_utils/robots.py:86–96  ·  view source on GitHub ↗

Check if the given URL is allowed for the given user agent. Args: url: The URL to check against the robots.txt rules. user_agent: The user-agent string to check permissions for. Defaults to '*' which matches any user-agent.

(self, url: str, user_agent: str = '*')

Source from the content-addressed store, hash-verified

84 return await cls.load(str(robots_url), http_client, proxy_info)
85
86 def is_allowed(self, url: str, user_agent: str = '*') -> bool:
87 """Check if the given URL is allowed for the given user agent.
88
89 Args:
90 url: The URL to check against the robots.txt rules.
91 user_agent: The user-agent string to check permissions for. Defaults to '*' which matches any user-agent.
92 """
93 check_url = URL(url)
94 if check_url.origin() != self._original_url:
95 return True
96 return bool(self._robots.can_fetch(str(check_url), user_agent))
97
98 def get_sitemaps(self, *, enqueue_strategy: EnqueueStrategy) -> list[str]:
99 """Get the list of sitemap URLs from the robots.txt file, filtered by enqueue strategy.

Calls

no outgoing calls

Tested by 4

test_parse_from_contentFunction · 0.64
test_bind_robots_txt_urlFunction · 0.64