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).

sclass LotteryResult {
  S date;
  L<Int> numbers;
  S jackpot;
  
  [stdToString]
}

static LotteryResult scrapeLotteryResults(S html) {
  LS tok = htmlTok(html);
  new LotteryResult result;
  
  S ball = [[ball--default">(\d+)</li>]];
  S jackpot = "(\\$[0-9,]+)";
  S regexp = "(?s)" + join(".*?",
    [[class="c-game-table__game-date"\s+datetime="(\d{4}-\d{2}-\d{2})"]],
    ball, ball, ball, ball, ball, jackpot);
  LS l = regexpGroups(regexp, html);
  result.date = assertNempty("Date", first(l));
  result.numbers = map parseInt(dropFirstAndLast(l));
  result.jackpot = last(l);
  ret result;
}

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: 151 / 228
Version history: 5 change(s)
Referenced in: [show references]