Given a list of URLs, request them in parallel and yield responses as they come in. Args: urls (list[str]): List of URLs to visit *args: Positional arguments to pass through to httpx **kwargs: Keyword arguments to pass through to httpx E
(self, urls, *args, **kwargs)
| 130 | return result |
| 131 | |
| 132 | async def request_batch(self, urls, *args, **kwargs): |
| 133 | """ |
| 134 | Given a list of URLs, request them in parallel and yield responses as they come in. |
| 135 | |
| 136 | Args: |
| 137 | urls (list[str]): List of URLs to visit |
| 138 | *args: Positional arguments to pass through to httpx |
| 139 | **kwargs: Keyword arguments to pass through to httpx |
| 140 | |
| 141 | Examples: |
| 142 | >>> async for url, response in self.helpers.request_batch(urls, headers={"X-Test": "Test"}): |
| 143 | >>> if response is not None and response.status_code == 200: |
| 144 | >>> self.hugesuccess(response) |
| 145 | """ |
| 146 | agen = self.run_and_yield("request_batch", urls, *args, **kwargs) |
| 147 | while 1: |
| 148 | try: |
| 149 | yield await agen.__anext__() |
| 150 | except (StopAsyncIteration, GeneratorExit): |
| 151 | await agen.aclose() |
| 152 | break |
| 153 | |
| 154 | async def request_custom_batch(self, urls_and_kwargs): |
| 155 | """ |