apify-sdk-python
apify-sdk-python copied to clipboard
AttributeError: 'KeyValueStore' object has no attribute 'get_public_url'
In the SDK documentation we can find that:
Public URLs of records To get a publicly accessible URL of a key-value store record, you can use the KeyValueStore.get_public_url() method.
print(f'"my_record" record URL: {await store.get_public_url('my_record')}')
but there is an error:
AttributeError: 'KeyValueStore' object has no attribute 'get_public_url'
Sample code that generates an error:
page = await context.new_page()
await page.goto(url)
screenshot = await page.screenshot(full_page=True)
key_value_store = await Actor.open_key_value_store()
screenshot_key = f"screenshot_{request.id}.png"
await key_value_store.set_value(
screenshot_key,
screenshot,
content_type="image/png",
)
screenshot_url = await key_value_store.get_public_url(
screenshot_key
)
I guess that as a temporary solution it can be hardcoded:
https://api.apify.com/v2/key-value-stores/{key_value_store.id}/records/{record_key}?attachment=true
Hello, there is an issue in crawlee-python tracking this - https://github.com/apify/crawlee-python/issues/514. We may want to update the docs before that is resolved.