python + 富途牛API 已經樓主做到99%既野
HKEPC852 發表於 2021-4-16 18:54



    同意, 拎人地做好既最好
唔好唸住自己搞了, 唔好話你唔識, 就算識整都唔會自己搞

TOP

同意, 拎人地做好既最好
唔好唸住自己搞了, 唔好話你唔識, 就算識整都唔會自己搞 ...
gn01119056 發表於 2021-4-22 14:31



    係,最後solution先考慮python + selenium去網站撈data,如果provider有api,老hi都api行先,有咩事api provider有support,如果真係無api做,second solution可以上github搵搵有無project有relay api做,因為有咩事,成個community幫手改code同debug,最後如果無曬辦法,先用python + selenium做,缺點係網站改少少layout,你成套program就炒車,改code改到你暈

TOP

本帖最後由 javacomhk 於 2021-5-27 17:45 編輯

NodeJS 加 puppeteer 都得嘅。話哂用JavaScript code 響chrome browser console 都用得番。又或者響chrome browser 搵到的 CSS selector 可以搬過去 nodejs 的script 度用。對於website 改版面或者的class or id name 係非常快可以改番正。

E.g. this code javascript snippet can be used to scrape the title, author and date of this sub-forum.  Just fire up a chrome or firefox browser and login to this subforum page https://www.hkepc.com/forum/forumdisplay.php?fid=26 and then paste the code in console (( Cmd + Opt + I in mac or Ctrl + Shift + I in win) and Run.  The same code base can be used in nodejs script for automation.
  1. document.querySelectorAll('tr').forEach(function(item) {
  2.   // console code needs to convert to object using Object.values().
  3.   const th = Object.values(item.querySelectorAll('th.subject'))[0];
  4.   if (typeof th !== 'undefined' &&  th !== null) {
  5.     console.log(th.textContent.trim());
  6.   };
  7.    const cite = Object.values(item.querySelectorAll('td.author > cite'))[0];
  8.    if (typeof cite !== 'undefined' &&  cite !== null) {
  9.      console.log(cite.textContent.trim());
  10.   };                 
  11.    const em = Object.values(item.querySelectorAll('td.author > em'))[0];
  12.    if (typeof em !== 'undefined' &&  em !== null) {
  13.      console.log(em.textContent.trim());
  14.   };                 
  15. });
複製代碼
  1. // Goto http://www.aastocks.com/tc/stocks/market/calendar.aspx
  2. var data = Array.from(
  3.   document.querySelectorAll('.crtRow')
  4. ).map(
  5.   row => Array.from(row.children).map(node => node.textContent.trim())
  6. ).map(
  7.   (row) => row[0].length === 0 ? [...row.slice(1)] : row
  8. ).map(
  9.   (row, idx, arr) => {
  10.     if (row.length === 1) return null;
  11.     const getLastMatch = (idx, arr) =>
  12.         arr[idx].length === 4 ? arr[idx] : getLastMatch(idx - 1, arr);
  13.     const match = getLastMatch(idx, arr);
  14.     const isSameDate = row.length === 3;
  15.     console.log(''.concat(match[0],' ',row[1-isSameDate*1],' ',row[2-isSameDate*1],' ',row[3-isSameDate*1],'\n'));
  16.     return {
  17.       date:match[0],
  18.       stock:row[1-isSameDate*1],
  19.       code:row[1-isSameDate*1].slice(-8).slice(0,5),
  20.       industry:row[2-isSameDate*1],
  21.       period:row[3-isSameDate*1]
  22.     }
  23.   }).filter(Boolean);
  24. console.log(data);

  25. // copy to clipboard
  26. copy(data)
複製代碼

TOP

回覆 3# it_jobs


    >想睇到全部股票既財務報表、可以比較唔同公司
電腦最叻係做重複嘅野, 有結構情. 財務報表(pdf?) 應該唔係, 唔同公司固然唔同, 同一公司唔同月份都可能唔同. 你要諗下點做到.  呢個可能要做 30日以上, 甚至根本不能自動化.

俾錢買,應該會有人做俾你。 整理paper.

TOP

回覆  it_jobs


    >想睇到全部股票既財務報表、可以比較唔同公司
電腦最叻係做重複嘅野, 有結構情. 財 ...
staymen 發表於 2021-5-10 00:35


咁咪即係唔可以自動化

TOP

Google sheet有 function可以取到股價

via HKEPC Reader for Android

TOP

看你作品方向,但看你的post,不是特別清晰,建議可以從這兩點做個規劃
1.bi
2.automatic

TOP

python + 富途牛API 已經樓主做到99%既野
HKEPC852 發表於 2021-4-16 18:54



富途牛API  之類要比錢先用到吧?

TOP

富途牛API  之類要比錢先用到吧?
hhmmss2016 發表於 2021-7-10 16:19



    試用左免費先,有d高級功能要課金先用到,不過都唔貴,$300左右/月

TOP

你1個人啊, 0 programming 知識, 無返3,5,7年都唔洗做得完整D功能
淨係咁多間公司每份報表唔同PATH, 唔同FORMAT, 唔同頁數, 或者隨時UPDATE公司網站, 仲要做validation都夠做死你

TOP