• (022) 8788 2588

Scraper utk menyimpan real time feeds ke database

 

Target web: https://www.indopremier.com/ipotstock/liveTradeWindowed.php

web tersebut di atas mendapatkan 'kiriman' real time feeds (dalam bentuk JSON data) dari https://www.indopremier.com/module/saham/include/livetrade-streaming.php

Real time feeds akan berjalan dgn jadwal berikut:

  1. Senin - Kamis: 9.15 - 12.15 dan 13.45 - 16.05
  2. Jumat: 9.15 - 11.45 dan 14.15 - 16.05

Scraper merupakan Javascript (pakai EventSource) yg ditulis dalam PHP.

Ketika dijalankan, scraper berfungsi untuk merekam, parsing real time feeds (server mengirimkan dalam bentuk JSON data), dan menyimpan ke dalam database MySQL localhost.

contoh JSON data:

id: 0
data: {"code":"13:31:53","data":{"Time":"13:31:53","TradeCommand":"0","SecurityCode":"SMBR","BoardCode":"RG","TradeNum":"000377613023","Price":"2420","Volume":44,"BuyerCode":"CS","BuyerType":"F","SellerCode":"LG","SellerType":"D","PrevPrice":"2400","TmpVar1":"000842681006","TmpVar2":"000842603483","Chg":"20","TmpVar4":"0","TmpVar5":"1\r","fmtPrice":"2,420 ","fmtChg":"20 ","fmtVolume":"44 ","fmtLabelSector":"basic"}}

Kolom pd tabel database localhost:

  1. Date (YYYY-MM-DD)
  2. Time
  3. TradeCommand
  4. SecurityCode
  5. BoardCode
  6. TradeNum
  7. Price
  8. Volume
  9. BuyerCode
  10. BuyerType
  11. SellerCode
  12. SellerType
  13. PrevPrice
  14. TmpVar1
  15. TmpVar2
  16. Chg
  17. TmpVar4
  18. TmpVar5
  19. fmtPrice
  20. fmtChg
  21. fmtVolume
  22. fmtLabelSector
Dalam PHP ada tombol "START" dan "STOP". START utk memulai aktivitas membangun koneksi, parsing, dan simpan data ke database. STOP utk menghentikan smua aktivitas tersebut.

Tampilan tidak penting. Buat sesederhana mungkin.

Budget <= Rp150.000

saya punya beberapa contoh javascript dalam PHP yg mungkin bs jd acuan dan selanjutnya dikembangkan sendiri. ada di attachment.

Attachments:
contohskrip.php

MySQL JavaScript PHP Web Scrapping

Project Class: Micro (Under 500rb)
Published Date: 21/11/2016 14:57:52 WIB
Published Budget: Rp 150,000
Finish Days: 2
Project Status: Published
Bid Count: 3
Select Deadline: 21/12/2016 14:57:52 WIB
Need Weekly Report:

Project Owner

tommytama
    
10.00/10.00
17 Point
#1,461 dari 66,955

Accepted Worker

Bid masih terbuka.

  Place New Bid   Ask Owner   Chat

  User Bids

appzone
    
9.92/10.00

ilmu13
    
0.00/10.00

azanakbar
    
0.00/10.00