Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1025908 // scrapeLotteryResults

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2674L/17K).

1  
sclass LotteryResult {
2  
  S date;
3  
  L<Int> numbers;
4  
  S jackpot;
5  
  
6  
  [stdToString]
7  
}
8  
9  
static LotteryResult scrapeLotteryResults(S html) {
10  
  LS tok = htmlTok(html);
11  
  new LotteryResult result;
12  
  
13  
  S ball = [[ball--default">(\d+)</li>]];
14  
  S jackpot = "(\\$[0-9,]+)";
15  
  S regexp = "(?s)" + join(".*?",
16  
    [[class="c-game-table__game-date"\s+datetime="(\d{4}-\d{2}-\d{2})"]],
17  
    ball, ball, ball, ball, ball, jackpot);
18  
  LS l = regexpGroups(regexp, html);
19  
  result.date = assertNempty("Date", first(l));
20  
  result.numbers = map parseInt(dropFirstAndLast(l));
21  
  result.jackpot = last(l);
22  
  ret result;
23  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1025908
Snippet name: scrapeLotteryResults
Eternal ID of this version: #1025908/6
Text MD5: d0bd7a42259d5d00cdcc60792d48ca87
Transpilation MD5: e72f9f120a1c4c671b78bb99b832ad3f
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-19 20:47:06
Source code size: 623 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 236
Version history: 5 change(s)
Referenced in: [show references]