Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DummyResponse #226

Open
bulatbulat48 opened this issue Oct 14, 2024 · 5 comments
Open

DummyResponse #226

bulatbulat48 opened this issue Oct 14, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@bulatbulat48
Copy link

bulatbulat48 commented Oct 14, 2024

When we add a type hint DummyResponse to the response as it mentioned here:

The scrapy doesn't send the actions, experimental, cookies or other additional settings added to the settings or the the request:

Maybe it's a cloudflare related issue, idk.

cookies = {
    'bh_cookies_accepted': True,
    'bh_cookies_allow_all': True,
    'bh_cookies_allow_marketing': True,
    'bh_cookies_allow_statistic': True,
    'bh_cookies_allow_thirdcountries': True,
},
@classmethod
def update_settings(cls, settings: BaseSettings) -> None:
    settings["ZYTE_API_EXPERIMENTAL_COOKIES_ENABLED"] = True
    settings["ZYTE_API_LOG_REQUESTS"] = True
    settings["ZYTE_API_LOG_REQUESTS_TRUNCATE"] = 1000
    return super().update_settings(settings)
2024-09-26 20:40:50 [scrapy_poet.downloadermiddlewares] DEBUG: Using DummyResponse instead of downloading <GET https://www.example.com/>
2024-09-26 20:40:50 [scrapy_zyte_api.handler] DEBUG: Sending Zyte API extract request: {"browserHtml": true, "url": "https://www.example.com"}
@wRAR wRAR added the bug Something isn't working label Oct 15, 2024
@kmike
Copy link
Member

kmike commented Oct 15, 2024

@bulatbulat48 could you please also provide the example of the callback you're using? The signature is enough.

@bulatbulat48
Copy link
Author

bulatbulat48 commented Oct 15, 2024

@kmike sure:

async def parse_product(
        self, response: DummyResponse, product_dpo: ProductPageObject
):

@kmike
Copy link
Member

kmike commented Oct 15, 2024

What are the dependencies of ProductPageObject?

@bulatbulat48
Copy link
Author

@kmike

from web_poet import BrowserResponse, HttpResponse, ItemPage, PageParams, field

@attrs.define(auto_attribs=True)
class ProductPageObject(ItemPage[ProductItem]):
    response: BrowserResponse
    page_params: PageParams

@Gallaecio
Copy link
Contributor

The behavior here is as designed, Zyte API params for provider dependencies can only be altered with the zyte_api_provider request metadata key or the ZYTE_API_PROVIDER_PARAMS setting.

However, I wonder if for some parameters, like cookies, we should make things behave like automap, or at least make it easier for them to do that, instead of requiring those cookies to be specified in those settings as Zyte API params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants