Skip to content

Conversation

@Borda
Copy link

@Borda Borda commented Aug 8, 2024

addresses issue when data are not found in requested page, to reproduce:

import pandas_datareader.data as web # Fetch stock data using pandas_datareader def fetch_stock_data(symbol='AAPL', start_date='2020-01-01', end_date='2021-01-01'): df = web.DataReader(symbol, 'yahoo', start_date, end_date) return df['Close'].values print(fetch_stock_data())

cc: @bashtage

resp = self._get_response(url, params=params, headers=self.headers)
ptrn = r"root\.App\.main = (.*?);\n}\(this\)\);"
try:
j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a patter is not found it crashes with different exception:
AttributeError: 'NoneType' object has no attribute 'group'

@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.88%. Comparing base (a1cf7a2) to head (74f9a90).

Additional details and impacted files
@@ Coverage Diff @@ ## main #994 +/- ## ========================================== - Coverage 68.34% 66.88% -1.47%  ========================================== Files 65 65 Lines 2894 2893 -1 Branches 463 463 ========================================== - Hits 1978 1935 -43  - Misses 838 882 +44  + Partials 78 76 -2 
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants