mirror of https://github.com/scrapy/scrapy.git
25 lines
510 B
Python
25 lines
510 B
Python
import asyncio
|
|
|
|
from scrapy import Request, Spider
|
|
from scrapy.crawler import AsyncCrawlerRunner
|
|
from scrapy.utils.log import configure_logging
|
|
|
|
|
|
class DataSpider(Spider):
|
|
name = "data"
|
|
|
|
async def start(self):
|
|
yield Request("data:,foo")
|
|
|
|
def parse(self, response):
|
|
return {"data": response.text}
|
|
|
|
|
|
async def main() -> None:
|
|
configure_logging()
|
|
runner = AsyncCrawlerRunner(settings={"TWISTED_REACTOR_ENABLED": False})
|
|
await runner.crawl(DataSpider)
|
|
|
|
|
|
asyncio.run(main())
|