June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
31
Task/Web-scraping/Ceylon/web-scraping.ceylon
Normal file
31
Task/Web-scraping/Ceylon/web-scraping.ceylon
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import ceylon.uri {
|
||||
parse
|
||||
}
|
||||
import ceylon.http.client {
|
||||
get
|
||||
}
|
||||
|
||||
shared void run() {
|
||||
|
||||
// apparently the cgi link is deprecated?
|
||||
value oldUri = "http://tycho.usno.navy.mil/cgi-bin/timer.pl";
|
||||
value newUri = "http://tycho.usno.navy.mil/timer.pl";
|
||||
|
||||
value contents = downloadContents(newUri);
|
||||
value time = extractTime(contents);
|
||||
print(time else "nothing found");
|
||||
}
|
||||
|
||||
String downloadContents(String uriString) {
|
||||
value uri = parse(uriString);
|
||||
value request = get(uri);
|
||||
value response = request.execute();
|
||||
return response.contents;
|
||||
}
|
||||
|
||||
String? extractTime(String contents) =>
|
||||
contents
|
||||
.lines
|
||||
.filter((String element) => element.contains("UTC"))
|
||||
.first
|
||||
?.substring(4, 21);
|
||||
Loading…
Add table
Add a link
Reference in a new issue