| 167 | ) |
| 168 | |
| 169 | async def parse_with_rules( |
| 170 | self, |
| 171 | response: Response, |
| 172 | callback: CallbackT | None, |
| 173 | cb_kwargs: dict[str, Any], |
| 174 | follow: bool = True, |
| 175 | ) -> AsyncIterator[Any]: |
| 176 | if callback: |
| 177 | cb_res = callback(response, **cb_kwargs) or () |
| 178 | if isinstance(cb_res, AsyncIterator): |
| 179 | cb_res = await collect_asyncgen(cb_res) |
| 180 | elif isinstance(cb_res, Awaitable): |
| 181 | cb_res = await cb_res |
| 182 | cb_res = self.process_results(response, cb_res) |
| 183 | for request_or_item in iterate_spider_output(cb_res): |
| 184 | yield request_or_item |
| 185 | |
| 186 | if follow and self._follow_links: |
| 187 | for request_or_item in self._requests_to_follow(response): |
| 188 | yield request_or_item |
| 189 | |
| 190 | def _parse_response( |
| 191 | self, |