scrapy/tests/AsyncCrawlerProcess/reactorless_datauri.py

24 lines
453 B
Python

from scrapy import Request, Spider
from scrapy.crawler import AsyncCrawlerProcess
class DataSpider(Spider):
name = "data"
async def start(self):
yield Request("data:,foo")
def parse(self, response):
return {"data": response.text}
process = AsyncCrawlerProcess(
settings={
"TWISTED_REACTOR_ENABLED": False,
"COMPRESSION_KEEP_ENCODING_HEADER": True,
}
)
process.crawl(DataSpider)
process.start()