Comments (2)
我其實沒有用這個專案,只是參考了一下某些 url 位置然後寫了自己的私有專案。作為回報,以下是部份程式碼,不過設計架構還有邏輯和這個專案是不同的,但也許對某些人來說還是會有幫助 :-) ...
def fetch(self, code: str, year: int, month, retry: int = 5) -> List[Schema_Mongo_Stock_Document]:
params = {'d': '%d/%d' % (year - 1911, month), 'stkno': code}
for idx in range(retry):
try:
self.acquire()
r = requests.get(self.TARGET_URL, params=params)
if r.status_code != 200:
self.logger.info( f"({idx}) Got code '{r.status_code}': params: {params}" )
continue
raw_data = r.json()
return self.purify( raw_data, code, year, month )
except ValueError as err:
self.logger.info( f"({code}), err: {err}" )
continue
except ConnectionError as err:
self.logger.info( f"({code}), err: {err}" )
continue
except Exception as err:
self.logger.warning( f"({code}), err: {err}" )
continue
finally:
self.sleep( self.retrieve_interval )
self.release()
self.logger.warn(f" Too many retrys, sleep '{self.failure_interval}' seconds and raise exception.")
self.sleep( self.failure_interval )
raise Exception(f"Failed to fetch after '{retry}' times retry.")
from twstock.
Any chance that you can share your code or with a pull request?
from twstock.
Related Issues (20)
- http.client.RemoteDisconnected: Remote end closed connection without response
- 請問可以查詢ETF嗎 HOT 4
- 抓取大盤指數
- 查詢代號:1795時程式會出現錯誤 HOT 6
- realtime的latest_trade_price股價為 '-'
- Config file pyproject.toml does not exist after $flit init HOT 2
- 60日線 跟 240日線 無法顯示 HOT 2
- Unittest 總是遇到 AssertError HOT 3
- twstock.realtime.get() 查無資料 HOT 19
- 有提供盤中零股五檔報價功能嗎
- fetch 時間頗久
- 股票 1102 抓取1年內的資料遇到問題
- 抓取00878 30日收盤價 出現錯誤 HOT 1
- realtime 的 latest_trade_price 並未顯示查詢時最後的成交價 HOT 1
- 連線嘗試失敗 HOT 3
- SSL: CERTIFICATE_VERIFY_FAILED HOT 2
- realtime SSL issue HOT 1
- 我第一次要執行,發現股票清單比較舊,執行twstock -U卻始終timeout HOT 1
- After pyinstaller build exe, get error message HOT 1
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 twstock.