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 = '*')
| 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. |
no outgoing calls