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

16
LINES

< > BotCompany Repo | #1004103 // loadMediumJSON

JavaX fragment (include)

1  
sbool loadMediumJSON_verbose;
2  
static int loadMediumJSON_timeout = 60*1000;
3  
4  
// accepts raw username and "@username"
5  
static Map<S, O> loadMediumJSON(S username) {
6  
  S html = loadPageWithUserAgentAndTimeout("https://medium.com/" + addPrefix("@", username), "Mac Safari", loadMediumJSON_timeout);
7  
  if (loadMediumJSON_verbose) print(html);
8  
  
9  
  S prefix = [[window["obvInit"](]];
10  
  int i = indexOf(html, prefix);
11  
  if (i < 0) null;
12  
  int j = indexOf(html, "\n", i);
13  
  if (j < 0) null;
14  
  S json = dropSuffix(")", trim(substring(html, i+l(prefix), j)));
15  
  ret jsonDecodeMap(json);
16  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004103
Snippet name: loadMediumJSON
Eternal ID of this version: #1004103/1
Text MD5: 9e1677b26e92c94257cd774850479e12
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-28 17:52:27
Source code size: 592 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 541 / 509
Referenced in: [show references]