Coder Social home page Coder Social logo

Comments (6)

tosatoandrea avatar tosatoandrea commented on June 6, 2024 1

Ok thank you very much

from yahoofinanceapi.

dmitrypasyutin avatar dmitrypasyutin commented on June 6, 2024

@tosatoandrea now you must pass a "User agent" header in the request for crumb, similarly to how you make a request for cookies

from yahoofinanceapi.

tosatoandrea avatar tosatoandrea commented on June 6, 2024

Ok thank you, where exactly I can pass User Agent header?
I use only this code:

`try
{

                // You should be able to query data from various markets including US, HK, TW
                // The startTime & endTime here defaults to EST timezone
                var history = await Yahoo.GetHistoricalAsync("SWDA", new DateTime(2023, 1, 1), new DateTime(2023, 7, 7), Period.Monthly);

                foreach (var candle in history)
                {
                    string line = $"DateTime: {candle.DateTime}, Open: {candle.Open}, High: {candle.High}, Low: {candle.Low}, Close: {candle.Close}, Volume: {candle.Volume}, AdjustedClose: {candle.AdjustedClose}";
                    textBox1.AppendText(Environment.NewLine + line);
                }
                riuscito = true;
            }
            catch (Exception ex)
            {
                textBox1.AppendText(Environment.NewLine + ex.Message);
            }`

Thank you

from yahoofinanceapi.

dmitrypasyutin avatar dmitrypasyutin commented on June 6, 2024

@tosatoandrea the problem is in the library itself. So you should fork the source and modify method "InitAsync" in "YahooSession" class, The request for crumb should look like this:

_crumb = await "https://query1.finance.yahoo.com/v1/test/getcrumb"
                        .WithHeader(userAgentKey, userAgentValue)
                        .WithHeader("Accept", acceptHeader)
                        .WithCookie(_cookie.Name, _cookie.Value)
                        .GetAsync(token)
                        .ReceiveString();

Variables userAgentKey and userAgentValue are already defined in this method. The "Accept" header is not necessary AFAIK

from yahoofinanceapi.

DonWM avatar DonWM commented on June 6, 2024

Could someone with the authorization and knowledge update the package to a new version 2.3.0 or something, please?

Thanks!

from yahoofinanceapi.

tranb3r avatar tranb3r commented on June 6, 2024

I've prepared PR #60

from yahoofinanceapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.