node-yahoo-finance2 icon indicating copy to clipboard operation
node-yahoo-finance2 copied to clipboard

Yahoo Search return HTML error page

Open shinobijs opened this issue 1 month ago • 2 comments

Bug Report

Describe the bug

Yahoo search resulted in HTTP status 500, and return the error page HTML. I was expecting the search function to throw an exception.

Environment

Node: v22.20 Package: v3.10.0

Additional Context

The fetch code returns any responseText which can be HTML (see below exatract).

// We do this last as it generally contains less information (e.g. no desc).
if (!response.ok) {
    console.error(url);
    const error = new errors.HTTPError(responseText || response.statusText);
    error.code = response.status;
    throw error;
}
HTTPError: <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Yahoo! - Error report</title>
    <style>
    </style>
</head>
<body>
<div id="doc">
    <div id="ygma">
        <a href="http://www.yahoo.com">
            <img src="https://s.yimg.com/lq/a/i/yahoo.gif" width="147"
                 height="31" border="0" alt="Yahoo!">
        </a>

        <div>
            <a href="http://www.yahoo.com">Yahoo!</a>
            - <a href="http://help.yahoo.com">Help</a>
        </div>
    </div>
    <div id="bd">
        <h1>HTTP Status 500 - Internal Server Error</h1>
    </div>
</div>
</body>
</html>

shinobijs avatar Nov 10 '25 15:11 shinobijs

Ooh, thanks. It is still throwing an error, just a very verbose one 😅

Any chance this is reproduceable and you can explain how you got it?

In any event, we can definitely clean this up a bit. Thanks for raising!

gadicc avatar Nov 10 '25 18:11 gadicc

Hi, I noticed a couple of occurrences during a short time, and than everything was fine again. Nothing else in the logs.

shinobijs avatar Nov 10 '25 21:11 shinobijs