AI4Finance-Foundation / AI4Finance-Foundation/FinNLP

How to use download news

オープン
#31 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Jupyter Notebook
スター
1.5k
フォーク
276
PR マージ指標
30日以内にマージされた PR はありません

説明

May be, proxing url broken?

start_date = "2024-09-01"
end_date = "2024-09-31"
config = {
"use_proxy": "us_free", # use proxies to prvent ip blocking
"max_retry": 5,
"proxy_pages": 5,
"token": "XXXXXX" # Available at https://finnhub.io/dashboard <-- inputed finnhub token api
}

news_downloader = Finnhub_Date_Range(config) # init
news_downloader.download_date_range_stock(start_date,end_date) # Download headers
news_downloader.gather_content() # Download contents
df = news_downloader.dataframe
selected_columns = ["headline", "content"]
df[selected_columns].head(10)

------
---> 10 news_downloader = Finnhub_Date_Range(config) # init
11 news_downloader.download_date_range_stock(start_date,end_date) # Download headers
12 news_downloader.gather_content() # Download contents

File ~/gitlab/FinNLP/finnlp/data_sources/news/finnhub_date_range.py:16, in Finnhub_Date_Range.__init__(self, args)
15 def __init__(self, args = {}):
---> 16 super().__init__(args)
17 assert "token" in args.keys(), "Please input your finnhub token. Avaliable at https://finnhub.io/dashboard"
18 self.finnhub_client = finnhub.Client(api_key=args["token"])

File ~/gitlab/FinNLP/finnlp/data_sources/news/_base.py:6, in News_Downloader.__init__(self, args)
5 def __init__(self, args = {}):
----> 6 super().__init__(args)
7 pass

File ~/gitlab/FinNLP/finnlp/data_sources/_base.py:22, in FinNLP_Downloader.__init__(self, args)
20 else:
21 self.proxy_id = 0
---> 22 self.proxy_list = self._update_proxy()
23 else:
24 self.proxy_list = []

File ~/gitlab/FinNLP/finnlp/data_sources/_base.py:44, in FinNLP_Downloader._update_proxy(self)
42 return get_china_free_proxy(self.proxy_pages)
43 else:
---> 44 return get_us_free_proxy(self.proxy_pages)

File ~/gitlab/FinNLP/finnlp/utils/get_proxy.py:86, in get_us_free_proxy(pages)
84 content = scripts[3].xpath(".//text()")
85 pattern = re.compile('LIST",data:(.+),added:')
---> 86 result_list = pattern.findall(content[0])
87 result_list = result_list[0].strip("[{").strip("}]").split("},{")
89 for result in result_list:

IndexError: list index out of range

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。