diff --git a/pandas/io/html.py b/pandas/io/html.py
index 490c574463b9b..715f0c08546a3 100644
--- a/pandas/io/html.py
+++ b/pandas/io/html.py
@@ -897,7 +897,7 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs):
try:
tables = p.parse_tables()
- except Exception as caught:
+ except ValueError as caught:
# if `io` is an io-like object, check if it's seekable
# and try to rewind it before trying the next parser
if hasattr(io, "seekable") and io.seekable():
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
index 3678e32943b2e..2d8303632e723 100755
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -3271,24 +3271,29 @@ def converter(*date_cols):
)
else:
try:
- result = tools.to_datetime(
- date_parser(*date_cols), errors="ignore", cache=cache_dates
- )
- if isinstance(result, datetime.datetime):
- raise Exception("scalar parser")
- return result
+ parsed_cols = date_parser(*date_cols)
+ if isinstance(parsed_cols, datetime.datetime):
+ raise TypeError("scalar parser")
except Exception:
+ # Since `date_parser` is user-provided, we can't guess
+ # what it might raise.
+ dcs = parsing._concat_date_cols(date_cols)
try:
- return tools.to_datetime(
- parsing.try_parse_dates(
- parsing._concat_date_cols(date_cols),
- parser=date_parser,
- dayfirst=dayfirst,
- ),
- errors="ignore",
+ parsed = parsing.try_parse_dates(
+ dcs, parser=date_parser, dayfirst=dayfirst
)
except Exception:
+ # Since `date_parser` is user-provided, we can't guess
+ # what it might raise.
return generic_parser(date_parser, *date_cols)
+ else:
+ return tools.to_datetime(parsed, errors="ignore")
+
+ else:
+ result = tools.to_datetime(
+ parsed_cols, errors="ignore", cache=cache_dates
+ )
+ return result
return converter