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

Use payload in form-submit when no input_values are given #447

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions custom_components/multiscrape/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
self._parser = parser
self._should_submit = True
self._cookies = None
self._payload = None

def notify_scrape_exception(self):
"""Make sure form is re-submitted after an exception."""
Expand Down Expand Up @@ -134,13 +135,16 @@ async def async_submit(self, main_resource):
self._config_name,
)

input_fields.update(self._input_values)
if self._input_values is not None:

_LOGGER.debug(
"%s # Merged input fields with input data in config. Result: %s",
self._config_name,
input_fields,
)
input_fields.update(self._input_values)

_LOGGER.debug(
"%s # Merged input fields with input data in config. Result: %s",
self._config_name,
input_fields,
)
self._payload = input_fields

if not method:
method = "POST"
Expand All @@ -152,7 +156,7 @@ async def async_submit(self, main_resource):
"form_submit",
submit_resource,
method=method,
request_data=input_fields,
request_data=self._payload,
cookies=self._cookies
)
_LOGGER.debug(
Expand Down