From 88285e75b6b7a22689208c2d321a1eda60b64003 Mon Sep 17 00:00:00 2001 From: Kevin Toms Date: Wed, 17 Jan 2024 10:05:22 -0500 Subject: [PATCH 1/3] Add FAQ on making a blank request --- docs/faq.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index 20dd814df31..9df4490d462 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -405,6 +405,25 @@ or :class:`~scrapy.signals.headers_received` signals and raising a :ref:`topics-stop-response-download` topic for additional information and examples. +.. _faq-blank-request: + +How can I make a blank request? +------------------------------- + +.. code-block:: python + + from scrapy import Request + + yield Request( + url="data:,", + callback=self.your_call_back, + ) + +In this case, the URL is set to a data URI scheme. Data URLs allow you to include data +in-line in web pages as if they were external resources. The "data:" scheme with an empty +content (",") essentially creates a request to a data URL without any specific content. + + Running ``runspider`` I get ``error: No spider found in file: `` -------------------------------------------------------------------------- From 46f94ec9cb0f480999f018ceab4a5751abaf180e Mon Sep 17 00:00:00 2001 From: Kevin Toms Date: Wed, 17 Jan 2024 15:49:51 -0500 Subject: [PATCH 2/3] Fix test Wrap the yield line in a function to prevent throwing error when the code snippet is executed --- docs/faq.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 9df4490d462..0282fc6e255 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -414,10 +414,11 @@ How can I make a blank request? from scrapy import Request - yield Request( - url="data:,", - callback=self.your_call_back, - ) + def make_blank_request(your_call_back): + yield Request( + url="data:,", + callback=your_call_back, + ) In this case, the URL is set to a data URI scheme. Data URLs allow you to include data in-line in web pages as if they were external resources. The "data:" scheme with an empty From 9074c16497bde04f5d561df1d584abe2cc73f183 Mon Sep 17 00:00:00 2001 From: Kevin Toms Date: Thu, 18 Jan 2024 09:36:25 -0500 Subject: [PATCH 3/3] make suggestion --- docs/faq.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 0282fc6e255..2113b096435 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -414,11 +414,8 @@ How can I make a blank request? from scrapy import Request - def make_blank_request(your_call_back): - yield Request( - url="data:,", - callback=your_call_back, - ) + + blank_request = Request("data:,") In this case, the URL is set to a data URI scheme. Data URLs allow you to include data in-line in web pages as if they were external resources. The "data:" scheme with an empty