Comments (8)
from financials-extension.
Looking at a yahoo-XXX.html file in the .financials-extension directory I see that the crumb is 13 characters long. I'm not sure if this varies or is a new format, but changing the regular expression that matches the crumb from 11 characters to 13 solved the issue for me:
diff --git a/src/financials_yahoo.py b/src/financials_yahoo.py
index 4159dec..1533751 100644
--- a/src/financials_yahoo.py
+++ b/src/financials_yahoo.py
@@ -184,7 +184,7 @@ class Yahoo(BaseClient):
return 'Yahoo.getRealtime({}, {}) - handleCookiesAndConsent'.format(ticker, datacode)
try:
- r = r'\bcrumb=([^"]{11})"'
+ r = r'\bcrumb=([^"]{13})"'
pattern = re.compile(r)
match = pattern.search(text)
if match:
from financials-extension.
from financials-extension.
This is what I see:
data-url="https://query1.finance.yahoo.com/v7/finance/quote?fields=fiftyTwoWeekHigh%2CfiftyTwoWeekLow%2CfromCurrency%2CfromExchange%2CheadSymbolAsString%2ClogoUrl%2ClongName%2CmarketCap%2CmessageBoardId%2CoptionsType%2CregularMarketTime%2CregularMarketChange%2CregularMarketChangePercent%2CregularMarketOpen%2CregularMarketPrice%2CregularMarketSource%2CregularMarketVolume%2CpostMarketTime%2CpostMarketPrice%2CpostMarketChange%2CpostMarketChangePercent%2CpreMarketTime%2CpreMarketPrice%2CpreMarketChange%2CpreMarketChangePercent%2CshortName%2CtoCurrency%2CtoExchange%2CunderlyingExchangeSymbol%2CunderlyingSymbol&formatted=true&imgHeights=50&imgLabels=logoUrl&imgWidths=50&symbols=IBM&lang=en-US&region=US&crumb=yrtV8%2FbGiDQ"
So the "%2F" looks like a urlencoded character, but I'm unsure whether this is decoded before the pattern is matched. All I know is that I was seeing the "no crumb" error before the change and it worked afterwards. :)
from financials-extension.
OK, with further testing I see examples with no urlencoded characters and a length of 11, so my "fix" is no longer working
from financials-extension.
Something like this allows the matched string to be longer but ensures the crumb is 11 characters after it is decoded:
diff --git a/src/financials_yahoo.py b/src/financials_yahoo.py
index 1533751..502f5f2 100644
--- a/src/financials_yahoo.py
+++ b/src/financials_yahoo.py
@@ -184,11 +184,13 @@ class Yahoo(BaseClient):
return 'Yahoo.getRealtime({}, {}) - handleCookiesAndConsent'.format(ticker, datacode)
try:
- r = r'\bcrumb=([^"]{11})"'
+ r = r'\bcrumb=([^"]{11,17})"'
pattern = re.compile(r)
match = pattern.search(text)
if match:
- self.crumb = urllib.parse.unquote(match.group(1))
+ crumb = urllib.parse.unquote(match.group(1))
+ if len(crumb) == 11:
+ self.crumb = crumb
except BaseException as e:
logger.exception("BaseException ticker=%s datacode=%s", ticker, datacode)
del self.realtime[ticker]
from financials-extension.
from financials-extension.
After some feedback from @szweep I have made some more changes to crumb handling. I'm pretty confident this is is improving things, so if anybody wants to have a go try the new release 3.6.2
from financials-extension.
Related Issues (20)
- Yahoo cookies. . . Again HOT 3
- Adding bond market quotes
- Financials Extension - Slow
- completely not working HOT 2
- looks like Yahoo changed again HOT 72
- No div yield or div data for ticker via FT
- Yahoo only showing price correctly, change X 100, nothing (?) for any other requests HOT 2
- Problems with scraping Yahoo and FT. Each is different. HOT 4
- Ditch Yahoo in favor of Barcharts, maybe?
- LibreOffice 24.2.2.2, Windows 10.0 Build 19045 and Financials -Extension 3.4.0 not working HOT 2
- GETREALTIME with "YAHOO" not working this morning HOT 16
- Thanks for this extension
- Please support retrieving 5 year Beta values for ETFs in Financial Times
- Error 508 HOT 3
- ETF Dividend
- URL with control characters HOT 2
- Nonblocking IO
- Is There A Way To Get the lastDividendValue
- GETHISTORIC not working since 2024-09-05 HOT 4
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 financials-extension.