Determine the location of a robots.txt file for a URL and fetch it. Args: url: The URL whose domain will be used to find the corresponding robots.txt file. http_client: Optional `ProxyInfo` to be used when fetching the robots.txt file. If None, no proxy is used.
(cls, url: str, http_client: HttpClient, proxy_info: ProxyInfo | None = None)
| 73 | |
| 74 | @classmethod |
| 75 | async def find(cls, url: str, http_client: HttpClient, proxy_info: ProxyInfo | None = None) -> Self: |
| 76 | """Determine the location of a robots.txt file for a URL and fetch it. |
| 77 | |
| 78 | Args: |
| 79 | url: The URL whose domain will be used to find the corresponding robots.txt file. |
| 80 | http_client: Optional `ProxyInfo` to be used when fetching the robots.txt file. If None, no proxy is used. |
| 81 | proxy_info: The `HttpClient` instance used to perform the network request for fetching the robots.txt file. |
| 82 | """ |
| 83 | robots_url = URL(url).with_path('/robots.txt') |
| 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. |