D4Vinci/Scrapling · error · TypeError
Only string values are accepted for arguments
Error message
Only string values are accepted for arguments
What it means
Keyword arguments passed to find_all() must have string values, since kwargs are translated into CSS attribute selectors like tag[attr="value"]. A non-string kwarg value (int, bool, list, None) fails the all() check and raises TypeError before any searching starts.
Source
Thrown at scrapling/parser.py:751
)
attributes.update(arg)
elif isinstance(arg, re_Pattern):
patterns.add(arg)
elif callable(arg):
if len(signature(arg).parameters) > 0:
functions.append(arg)
else:
raise TypeError(
"Callable filter function must have at least one argument to take `Selector` objects."
)
else:
raise TypeError(f'Argument with type "{type(arg)}" is not accepted, please read the docs.')
if not all([(isinstance(k, str) and isinstance(v, str)) for k, v in kwargs.items()]):
raise TypeError("Only string values are accepted for arguments")
for attribute_name, value in kwargs.items():
# Only replace names for kwargs, replacing them in dictionaries doesn't make sense
attribute_name = _whitelisted.get(attribute_name, attribute_name)
attributes[attribute_name] = value
# It's easier and faster to build a selector than traversing the tree
tags = tags or set("*")
for tag in tags:
selector = tag
for key, value in attributes.items():
value = value.replace('"', r"\"") # Escape double quotes in user input
# Not escaping anything with the key so the user can pass patterns like {'href*': '/p/'} or get errors :)
selector += '[{}="{}"]'.format(key, value)
if selector != "*":
selectors.append(selector)
if selectors:View on GitHub (pinned to 5d213a2d47)
Solutions
- Stringify values when building kwargs: {'data-count': str(val)}.
- For boolean attributes use the string form: find_all('input', disabled='disabled') rather than disabled=True.
- Skip None values when forwarding: {k: v for k, v in attrs.items() if v is not None}.
Example fix
# before
selector.find_all('input', data_count=3) # TypeError
# after
selector.find_all('input', data_count='3') Defensive patterns
Strategy: validation
Validate before calling
kwargs = {k: str(v) for k, v in kwargs.items() if v is not None}
selector.find_all('div', **kwargs) Type guard
def kwargs_are_strings(kwargs: dict) -> bool:
return all(isinstance(v, str) for v in kwargs.values()) Prevention
- Stringify all kwarg values coming from config/JSON before forwarding to find_all().
- Use the string form for boolean HTML attributes (disabled='disabled').
When it happens
Trigger: find_all('div', data_count=3), find_all(id=123), or find_all('a', href=None). Note the check applies only to values — keys are Python identifiers and inherently strings.
Common situations: Forwarding **kwargs from a config dict or JSON where numbers are parsed as int/float; passing a count limit kwarg that collides with an attribute filter.
Related errors
- Nested Iterables are not accepted, only iterables of tag nam
- Nested dictionaries are not accepted, only string keys and s
- Argument with type "{type(arg)}" is not accepted, please rea
- Response meta should be dictionary but got {type(meta).__nam
- Invalid proxy string: {proxy_string}
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/1df31894caea9cc4.
Report an issue: GitHub.