Open zxzxzxzx6666 opened 2 years ago
感謝您分享,該問題先前已有讀者反應~可參考:https://github.com/arleigh418/python-and-Taiwan-stock-market#yahoo%E8%82%A1%E5%B8%82%E7%B6%B2%E7%AB%99%E6%9B%B4%E6%96%B0
該網頁在書籍上市不久後即變更了版型.
老師 您好 我試跑第二章的範例文件除了stock_list.py之外 執行都沒有回傳東西 大概如圖片這樣 也有看過網站更新的文件 後來再試 也無法 不知道是哪裡出問題了呢 謝謝
hi 您好, 我不確定您是直接跑程式嗎? 如果是的話,因為我們上傳到github上面的都是函數(def),您需要透過引用函數並傳值,才會有相應的輸出.
請問如何取得全部的新聞 https://tw.stock.yahoo.com/quote/2330/news 越往下拉越多 謝謝
hi 您好, 基本上方法有2, 都與書上沒有教到的selenium有關係, 您可以先去玩玩相關技術.
熟悉之後, 大致上就是:
selenium是個很廣泛運用的工具, 雖然書上沒說 (因為說這個要講很多,可能會把我們想要講python與股市的主題帶篇) , 不過很建議您去玩玩看, 未來無論是做自動化或是搶票、ig、fb點讚、自動化測試都有效.如果您嘗試過程中有問題, 歡迎隨時提出討論一下囉.
另原程式碼跑出的所有新聞連結 點按後都會到Yahoo奇摩首頁 再麻煩了
hi 您好, 或許是您使用編譯器直接點擊連結,因為顯示被截斷故網址不正確被導向首頁. 您可以幫我嘗試看看將data frame匯成excel後,打開excel的完整連結作嘗試嗎?
如若狀況仍一樣,我會再去看一下.
xlsx檔OK是沒錯 但不方便 請問有解決網址截斷的方法嗎
hi 您好,
有的,但是整體的data frame會長得比較醜而已,截斷是為了美觀.
嘗試設置以下程式,在print出dataframe之前.
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
您好 不好意思 還是一樣
0 https://tw.stock.yahoo.com/news/%E3%80%90-hot%... 1 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 2 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 3 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 4 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 5 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 6 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 7 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 8 https://tw.stock.yahoo.com/news/%E5%B7%A6%E7%8... 9 https://tw.stock.yahoo.com/news/%E5%BC%B5%E5%B... 10 https://tw.stock.yahoo.com/news/%E8%B7%9F%E6%9... 11 https://tw.stock.yahoo.com/news/%E8%81%AF%E7%9... 12 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 13 https://tw.stock.yahoo.com/news/1%E5%88%86%E9%... 14 https://tw.stock.yahoo.com/news/%E8%81%AF%E7%9... 15 https://tw.stock.yahoo.com/news/%E5%85%AC%E5%9... 16 https://tw.stock.yahoo.com/news/2021%E5%B9%B4%... 17 https://tw.stock.yahoo.com/news/%E8%81%AF%E7%9... 18 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... 19 https://tw.stock.yahoo.com/news/%E5%8F%B0%E7%A... Name: url, dtype: object
sorry, 是我少複製一行! 將以下程式放在print出dataframe之前即可.如果有少數欄位仍然遮蔽,比1000再調更大. pd.set_option('display.max_rows', None) pd.set_option('display.max_columns', None) pd.set_option('display.width', None) pd.set_option('max_colwidth',1000)
終於有效了 感恩
更改後恢復正常
find尋找元素