Comments (14)
@kamoco My code now looks like this:
public static async Task InitAsync(CancellationToken token = default)
{
if (_crumb != null)
{
return;
}
await _semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
const string userAgentKey = "User-Agent";
const string userAgentValue = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = await "https://login.yahoo.com"
.AllowHttpStatus("404")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (response.Cookies.Count == 0)
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
from yahoofinanceapi.
me too, since since Dec. 4 too
from yahoofinanceapi.
I am hitting the same too.
from yahoofinanceapi.
found a workaround that seems to work.
In the InitAsync method of the "internal static class YahooSession" class:
-on the line : var response = await "https://login.yahoo.com"
-replace login with fc
-replace the line "_cookie = response.Cookies[0];"
-with : _cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
from yahoofinanceapi.
Those changes did not work. The response here still throws 502. May be you have some other changes on machine that helped along with these 2 changes ?
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("404")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
from yahoofinanceapi.
The workaround from @emoreau99 worked well for me, with the following clarification:
-replace login with fc
For me, I did the opposite. I had "fc.yahoo.com" on that line, and I replaced it with "login.yahoo.com". Everything worked then. The implication being that "fc.yahoo.com" is no longer responding.
from yahoofinanceapi.
hmm I tried both and none of them worked.
from yahoofinanceapi.
This worked for me:
change login to fc
Allow 502
replace the _cookie line - _cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("502")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (response.Cookies.Count == 0)
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
//_cookie = response.Cookies[0];
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
from yahoofinanceapi.
For me the request to "https://fc.yahoo.com" runs into a timeout and if I try "https://login.yahoo.com" I only get a cookie with name "AS". With this cookie the next request (_crumb = await "https://query1.finance.yahoo.com/v1/test/getcrumb") throws an error.
from yahoofinanceapi.
Same as above. Location in Germany, just in case this matters.
Note I used _cookie = response.Cookies[0] as the above suggested FirstOrDefault fails.
The fetched _cookie has Name is "AS" and Value a very long string.
The exception message is:
"Call failed with status code 500 (Internal Server Error): GET https://query1.finance.yahoo.com/v1/test/getcrumb"
from yahoofinanceapi.
I missed the part with "Allow 502". With this change it works again. Thank you @kamoco !
This is how my method looks now:
public static async Task InitAsync(CancellationToken token = default)
{
if (_crumb != null)
{
return;
}
await _semaphore.WaitAsync(token).ConfigureAwait(false);
try
{
const string userAgentKey = "User-Agent";
const string userAgentValue = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = await "https://fc.yahoo.com/"
.AllowHttpStatus("502")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
if (!response.Cookies.Any(c => c.Name == "A3"))
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
else
{
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");
_crumb = await "https://query1.finance.yahoo.com/v1/test/getcrumb"
.WithCookie(_cookie.Name, _cookie.Value)
.WithHeader(userAgentKey, userAgentValue)
.GetAsync(token)
.ReceiveString();
if (string.IsNullOrEmpty(_crumb))
{
throw new Exception("Failed to retrieve Yahoo crumb.");
}
}
}
finally
{
_semaphore.Release();
}
}
from yahoofinanceapi.
Thanks mate! Changing to 502 worked for me too!
I noticed though that the invocation of the following takes long time to complete. About 30 secs. Any idea why this is happening?
I guess is some timeout setting. At least, it is invoked only once and afterwards the feeds are fetched without delay by using the discovered cookie.
var response = await "https://fc.yahoo.com"
.AllowHttpStatus("502")//works after 5.12.23
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);
from yahoofinanceapi.
Thank all, I had same problem and its now working again.
from yahoofinanceapi.
from yahoofinanceapi.
Related Issues (20)
- Dividend Date HOT 1
- Exchange rate? HOT 1
- DividendDate issue HOT 1
- Empty dictionary? HOT 2
- stock split before after data is always zero HOT 4
- Can I retrieve historical data by hour?
- Exception: Failure to create client HOT 27
- Is 3.0.0-beta3 the final version?
- v7 API now breaks with "code":"Unauthorized","description":"Invalid Cookie" HOT 16
- Failed with status code 403 on Android HOT 1
- Premarket data HOT 1
- Error Too Many Requests HOT 6
- Flurl.Http dependencies issues HOT 1
- Call failed with status code 500 HOT 1
- FlurlHttpException with StatusCode: 429, ReasonPhrase: 'Too Many Requests' HOT 10
- Error code 500 (Cannot find server.): GET https://fc.yahoo.com HOT 2
- Stock split question HOT 1
- Can't install nuget: Cycle Detected
- Flurl.Http.FlurlHttpException: 'Call failed with status code 429 (Too Many Requests): HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yahoofinanceapi.