scheb / yahoo-finance-api

PHP client for Yahoo Finance API 📈
MIT License
279 stars 55 forks source link

Yahoo! We will right back... #45

Closed yasinaslan16 closed 4 weeks ago

yasinaslan16 commented 11 months ago

https://fc.yahoo.com/ is problematic because the system is running extremely slow and sometimes gives errors. Has anyone found an alternative solution? WhatsApp Image 2023-12-06 at 13 45 22

N1njaWTF commented 10 months ago

I'm wondering about this issue too.. its become extremely slow the past few weeks.

Have you found a solution?

vikrampant commented 10 months ago

I tweaked the $initialUrl in ApiClient.php around line 212. Grabbing that initial cookie from another Yahoo site vs fc.yahoo.

$initialUrl = 'https://sports.yahoo.com';

scheb commented 10 months ago

I see the issue of slowness with the fc.yahoo.com domain as well. Though I haven't found a good alternative yet.

The suggested sports.yahoo.com doesn't do it for me, as I'm getting "Invalid Cookie" errors further down the line.

vikrampant commented 10 months ago

Forgot to mention I also added another value in the header to the user agent. I pulled that from other Guzzle-based scripts I've used in the past.

public function getHeaders(): array
    {
        return [
            'User-Agent' => $this->userAgent,
            'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        ];
    }
scheb commented 10 months ago

Thanks for the hint! That gets the call to sports.yahoo.com working, but it doesn't initialize an A3 cookie (fc.yahoo.com does). I get a GUCS cookie instead and that doesn't seem to be sufficient to retrieve a crumb. Fetching a crumb gets me a error 500 response back.

I believe it has something to do with different locations. Especially in the EU (I'm in Germany) where we have GDPR, you have to accept the terms and conditions to get proper cookies initialized.

N1njaWTF commented 9 months ago

did anyone find a solution yet? :) for my tool i programmed, its very unfortunate to have such long loading times when trying to query something from Yahoo Finance..