Task

Create a program that downloads the time from this URL:   http://tycho.usno.navy.mil/cgi-bin/timer.pl   and then prints the current UTC time by extracting just the UTC time from the web page's HTML. Alternatively, if the above url is not working, grab the first date/time off this page's talk page.



If possible, only use libraries that come at no extra monetary cost with the programming language and that are widely available and popular such as CPAN for Perl or Boost for C++.




 
Module Web_scraping {
	Print "Web scraping"
	function GetTime$(a$, what$="UTC") {
		document a$ ' change string to document
		find a$, what$  ' place data to stack
		Read find_pos
		if find_pos>0 then
			read par_order, par_pos
			b$=paragraph$(a$, par_order)
			k=instr(b$,">")
			if k>0 then if k<par_pos then b$=mid$(b$,k+1) :par_pos-=k
			k=rinstr(b$,"<")
			if k>0 then if k>par_pos then b$=Left(b$,k-1)
			=b$
		end if
	}
	declare msxml2 "MSXML2.XMLHTTP.6.0"
	rem print type$(msxml2)="IXMLHTTPRequest"
	Url$ = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
	try ok {
		method msxml2, "Open", "GET", url$, false
		method msxml2,"Send"
		with msxml2,"responseText" as txt$
		Print GetTime$(txt$)
	}
	If error or not ok then Print Error$
	declare msxml2 nothing
}
Web_scraping
 