0

I need to parse a Yahoo Finance RSS news feed and display some information on a webpage but I don't know if I'm parsing correctly and how to display the information. I've tried many things but can't seem to figure it out. Hopefully this is easy for someone and is willing to help me out.

This is the tutorial I've ended up following: How to parse an RSS feed using JavaScript? but they exclude vital parts of coding to make the whole system work. I want to run everything from one .html page.

My current code just shows a blank screen, and in the chrome browser console I get the following message:

"Access to XMLHttpRequest at 'https://feeds.finance.yahoo.com/rss/2.0/headline?s=yhoo&region=US&lang=en-US' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">

    FEED_URL = "https://feeds.finance.yahoo.com/rss/2.0/headline?s=yhoo&region=US&lang=en-US"

    $.get(FEED_URL, function (data) {
        $(data).find("entry").each(function () { 
            var el = $(this);
            console.log(el.find("title").text());

        });
    });

</script>

</body>
</html>
Eddie
  • 26,593
  • 6
  • 36
  • 58
James Miller
  • 121
  • 2
  • 12

1 Answers1

-1

CORS issues, in general, can only be solve in the server side, in this case, Yahoo.

I really recomend that you start to use a an API instead RSS. Take a look at: https://rapidapi.com/apidojo/api/yahoo-finance1

Regards.

  • 1
    It isn't true that RSS is no longer recommended. RSS and Atom both continue to be widely supported by feed producers and feed-reading software. – rcade Apr 24 '19 at 14:24