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

36
LINES

< > BotCompany Repo | #1003988 // Parse Pouet Comments [works]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2836L/20K/64K).

!752

p {
  S arg = or(get(args, 0), "#3000391");
  S s = loadSnippetOrPage(arg);
  
  L<S> tok = htmlTok(s);

  int n = 0;
  for (int i : indexesOfLinesStartingWith(tok, "<div class='comment")) pcall {
    int j = findEndOfContainerTag(tok, i);
    L<S> tok2 = subList(tok, i+1, j-1);
    //print("Yo: " + join(subList(tok, i, j)) + "\n");
    
    j = indexOfStartsWith(tok2, "<div class='content'");
    int k = findEndOfContainerTag(tok2, j);
    S comment = join(subList(tok2, j+1, k-1)).trim();
    
    int u = indexOfEndsWith(tok2, "class='user'>");
    S user = u < 0 ? "?" : tok2.get(u+1);
    
    S vote = "+-";
    if (tok2.contains("<span class='vote rulez'>"))
      vote = "+";
    else if (tok2.contains("<span class='vote sucks'>"))
      vote = "-";
    
    //print(vote + " comment by " + quote(user) + ": " + htmldecode(comment));
    print(htmldecode(comment));
    print("  " + vote + " [" + user + "]");
    print();
    ++n;
  }
  
  print(n(n, "comment") + " found on " + arg);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003988
Snippet name: Parse Pouet Comments [works]
Eternal ID of this version: #1003988/1
Text MD5: 1e66c76fede2c285cd37aae0d42e7b00
Transpilation MD5: f662f3399e1efe499559d358625d5343
Author: stefan
Category: javax / networking
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-23 23:09:02
Source code size: 1041 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 581 / 607
Referenced in: [show references]