Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
14
Task/Web-scraping/8th/web-scraping.8th
Normal file
14
Task/Web-scraping/8th/web-scraping.8th
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
\ Web-scrape sample: get UTC time from the US Naval Observatory:
|
||||
: read-url \ -- s
|
||||
"http://tycho.usno.navy.mil/cgi-bin/timer.pl" net:get
|
||||
not if "Could not connect" throw then
|
||||
>s ;
|
||||
|
||||
: get-time
|
||||
read-url
|
||||
/<BR>.*?(\d{2}:\d{2}:\d{2})\sUTC/
|
||||
tuck r:match if
|
||||
1 r:@ . cr
|
||||
then ;
|
||||
|
||||
get-time bye
|
||||
9
Task/Web-scraping/App-Inventor/web-scraping.app
Normal file
9
Task/Web-scraping/App-Inventor/web-scraping.app
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
when ScrapeButton.Click do
|
||||
set ScrapeWeb.Url to SourceTextBox.Text
|
||||
call ScrapeWeb.Get
|
||||
|
||||
when ScrapeWeb.GotText url,responseCode,responseType,responseContent do
|
||||
initialize local Left to split at first text (text: get responseContent, at: PreTextBox.Text)
|
||||
initialize local Right to "" in
|
||||
set Right to select list item (list: get Left, index: 2)
|
||||
set ResultLabel.Text to select list item (list: split at first (text:get Right, at: PostTextBox.Text), index: 1)
|
||||
5
Task/Web-scraping/FunL/web-scraping.funl
Normal file
5
Task/Web-scraping/FunL/web-scraping.funl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import io.Source
|
||||
|
||||
case Source.fromURL( 'http://tycho.usno.navy.mil/cgi-bin/timer.pl', 'UTF-8' ).getLines().find( ('Eastern' in) ) of
|
||||
Some( time ) -> println( time.substring(4) )
|
||||
None -> error( 'Easter time not found' )
|
||||
27
Task/Web-scraping/Lasso/web-scraping.lasso
Normal file
27
Task/Web-scraping/Lasso/web-scraping.lasso
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* have to be used
|
||||
local(raw_htmlstring = '<TITLE>What time is it?</TITLE>
|
||||
<H2> US Naval Observatory Master Clock Time</H2> <H3><PRE>
|
||||
<BR>Jul. 27, 22:57:22 UTC Universal Time
|
||||
<BR>Jul. 27, 06:57:22 PM EDT Eastern Time
|
||||
<BR>Jul. 27, 05:57:22 PM CDT Central Time
|
||||
<BR>Jul. 27, 04:57:22 PM MDT Mountain Time
|
||||
<BR>Jul. 27, 03:57:22 PM PDT Pacific Time
|
||||
<BR>Jul. 27, 02:57:22 PM AKDT Alaska Time
|
||||
<BR>Jul. 27, 12:57:22 PM HAST Hawaii-Aleutian Time
|
||||
</PRE></H3>
|
||||
')
|
||||
*/
|
||||
|
||||
// should be used
|
||||
local(raw_htmlstring = string(include_url('http://tycho.usno.navy.mil/cgi-bin/timer.pl')))
|
||||
|
||||
local(
|
||||
reg_exp = regexp(-find = `<br>(.*?) UTC`, -input = #raw_htmlstring, -ignorecase),
|
||||
datepart_txt = #reg_exp -> find ? #reg_exp -> matchstring(1) | string
|
||||
)
|
||||
|
||||
#datepart_txt
|
||||
'<br />'
|
||||
// added bonus showing how parsed string can be converted to date object
|
||||
local(mydate = date(#datepart_txt, -format = `MMM'.' dd',' HH:mm:ss`))
|
||||
#mydate -> format(`YYYY-MM-dd HH:mm:ss`)
|
||||
5
Task/Web-scraping/Nim/web-scraping.nim
Normal file
5
Task/Web-scraping/Nim/web-scraping.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import httpclient, strutils
|
||||
|
||||
for line in getContent("http://tycho.usno.navy.mil/cgi-bin/timer.pl").splitLines:
|
||||
if " UTC" in line:
|
||||
echo line[4..line.high]
|
||||
5
Task/Web-scraping/Peloton/web-scraping-1.peloton
Normal file
5
Task/Web-scraping/Peloton/web-scraping-1.peloton
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<@ DEFAREPRS>Rexx Parse</@>
|
||||
<@ DEFPRSLIT>Rexx Parse|'<BR>' UTCtime 'UTC'</@>
|
||||
<@ LETVARURL>timer|http://tycho.usno.navy.mil/cgi-bin/timer.pl</@>
|
||||
<@ ACTRPNPRSVAR>Rexx Parse|timer</@>
|
||||
<@ SAYVAR>UTCtime</@>
|
||||
5
Task/Web-scraping/Peloton/web-scraping-2.peloton
Normal file
5
Task/Web-scraping/Peloton/web-scraping-2.peloton
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<# DEFINE WORKAREA PARSEVALUES>Rexx Parse</#>
|
||||
<# DEFINE PARSEVALUES LITERAL>Rexx Parse|'<BR>' UTCtime 'UTC'</#>
|
||||
<# LET VARIABLE URLSOURCE>timer|http://tycho.usno.navy.mil/cgi-bin/timer.pl</#>
|
||||
<# ACT REPLACEBYPATTERN PARSEVALUES VARIABLE>Rexx Parse|timer</#>
|
||||
<# SAY VARIABLE>UTCtime</#>
|
||||
1
Task/Web-scraping/Peloton/web-scraping-3.peloton
Normal file
1
Task/Web-scraping/Peloton/web-scraping-3.peloton
Normal file
|
|
@ -0,0 +1 @@
|
|||
<@ SAY AFT BEF URL LIT LIT LIT >http://tycho.usno.navy.mil/cgi-bin/timer.pl| UTC|<BR></@>
|
||||
4
Task/Web-scraping/Sidef/web-scraping.sidef
Normal file
4
Task/Web-scraping/Sidef/web-scraping.sidef
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var ua = frequire('LWP::Simple');
|
||||
var url = 'http://tycho.usno.navy.mil/cgi-bin/timer.pl';
|
||||
var match = /<BR>(.+? UTC)/.match(ua.get(url));
|
||||
say match[0] if match;
|
||||
3
Task/Web-scraping/ToffeeScript/web-scraping.toffee
Normal file
3
Task/Web-scraping/ToffeeScript/web-scraping.toffee
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
e, page = require('request').get! 'http://tycho.usno.navy.mil/cgi-bin/timer.pl'
|
||||
l = line for line in page.body.split('\n') when line.indexOf('UTC')>0
|
||||
console.log l.substr(4,l.length-20)
|
||||
3
Task/Web-scraping/jq/web-scraping-1.jq
Normal file
3
Task/Web-scraping/jq/web-scraping-1.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
curl -Ss 'http://tycho.usno.navy.mil/cgi-bin/timer.pl' |\
|
||||
jq -R -r 'if index(" UTC") then .[4:] else empty end'
|
||||
2
Task/Web-scraping/jq/web-scraping-2.jq
Normal file
2
Task/Web-scraping/jq/web-scraping-2.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ ./Web_scraping.jq
|
||||
Apr. 21, 05:19:32 UTC Universal Time
|
||||
Loading…
Add table
Add a link
Reference in a new issue