Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
34
Task/Web-scraping/Ada/web-scraping.adb
Normal file
34
Task/Web-scraping/Ada/web-scraping.adb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
with AWS.Client, AWS.Response, AWS.Resources, AWS.Messages;
|
||||
with Ada.Text_IO, Ada.Strings.Fixed;
|
||||
use Ada, AWS, AWS.Resources, AWS.Messages;
|
||||
|
||||
procedure Get_UTC_Time is
|
||||
|
||||
Page : Response.Data;
|
||||
File : Resources.File_Type;
|
||||
Buffer : String (1 .. 1024);
|
||||
Position, Last : Natural := 0;
|
||||
S : Messages.Status_Code;
|
||||
begin
|
||||
Page := Client.Get ("http://tycho.usno.navy.mil/cgi-bin/timer.pl");
|
||||
S := Response.Status_Code (Page);
|
||||
if S not in Success then
|
||||
Text_IO.Put_Line
|
||||
("Unable to retrieve data => Status Code :" & Image (S) &
|
||||
" Reason :" & Reason_Phrase (S));
|
||||
return;
|
||||
end if;
|
||||
|
||||
Response.Message_Body (Page, File);
|
||||
while not End_Of_File (File) loop
|
||||
Resources.Get_Line (File, Buffer, Last);
|
||||
Position :=
|
||||
Strings.Fixed.Index
|
||||
(Source => Buffer (Buffer'First .. Last),
|
||||
Pattern => "UTC");
|
||||
if Position > 0 then
|
||||
Text_IO.Put_Line (Buffer (5 .. Position + 2));
|
||||
return;
|
||||
end if;
|
||||
end loop;
|
||||
end Get_UTC_Time;
|
||||
52
Task/Web-scraping/FreeBASIC/web-scraping.basic
Normal file
52
Task/Web-scraping/FreeBASIC/web-scraping.basic
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
' Linux: fbc programa.bas
|
||||
' Windows: install wget (winget install GnuWin32.WGet) & fbc programa.bas
|
||||
|
||||
Dim As String sContent, sUTC, sRFC850, tmpFile, cmd
|
||||
|
||||
' Detect system and use temporary folder
|
||||
#Ifdef __FB_WIN32__
|
||||
tmpFile = Environ("TEMP") & "\utctime.html"
|
||||
cmd = "wget -q -O """ & tmpFile & """ https://www.utctime.net"
|
||||
#Else
|
||||
tmpFile = "/tmp/utctime.html"
|
||||
cmd = "wget -q -O " & tmpFile & " https://www.utctime.net"
|
||||
#EndIf
|
||||
|
||||
Shell cmd
|
||||
|
||||
Dim As Integer ff = Freefile
|
||||
If Open(tmpFile For Input As #ff) <> 0 Then
|
||||
Print "Error: wget failed or file is not accessible."
|
||||
Sleep: End
|
||||
End If
|
||||
|
||||
' Read full content
|
||||
sContent = ""
|
||||
While Not Eof(ff)
|
||||
Dim As String linea
|
||||
Line Input #ff, linea
|
||||
sContent &= linea & Chr(10)
|
||||
Wend
|
||||
Close #ff
|
||||
|
||||
' Extract UTC and RFC 850
|
||||
Dim As Integer utcStart = Instr(sContent, "UTC</td><td>")
|
||||
If utcStart > 0 Then
|
||||
utcStart += 12
|
||||
Dim As Integer utcEnd = Instr(utcStart, sContent, "</td>")
|
||||
If utcEnd > 0 Then sUTC = Rtrim(Mid(sContent, utcStart, utcEnd - utcStart))
|
||||
End If
|
||||
|
||||
Dim As Integer rfcStart = Instr(sContent, "RFC 850</td><td>")
|
||||
If rfcStart > 0 Then
|
||||
rfcStart += 16
|
||||
Dim As Integer rfcEnd = Instr(rfcStart, sContent, "</td>")
|
||||
If rfcEnd > 0 Then sRFC850 = Rtrim(Mid(sContent, rfcStart, rfcEnd - rfcStart))
|
||||
End If
|
||||
|
||||
Kill tmpFile
|
||||
|
||||
If sUTC <> "" Then Print "UTC: " & sUTC
|
||||
If sRFC850 <> "" Then Print "RFC 850: " & sRFC850
|
||||
|
||||
Sleep
|
||||
4
Task/Web-scraping/PowerShell/web-scraping-1.ps1
Normal file
4
Task/Web-scraping/PowerShell/web-scraping-1.ps1
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$wc = New-Object Net.WebClient
|
||||
$html = $wc.DownloadString('http://tycho.usno.navy.mil/cgi-bin/timer.pl')
|
||||
$html -match ', (.*) UTC' | Out-Null
|
||||
Write-Host $Matches[1]
|
||||
1
Task/Web-scraping/PowerShell/web-scraping-2.ps1
Normal file
1
Task/Web-scraping/PowerShell/web-scraping-2.ps1
Normal file
|
|
@ -0,0 +1 @@
|
|||
[System.DateTime]::UtcNow
|
||||
1
Task/Web-scraping/PowerShell/web-scraping-3.ps1
Normal file
1
Task/Web-scraping/PowerShell/web-scraping-3.ps1
Normal file
|
|
@ -0,0 +1 @@
|
|||
[System.DateTime]::Now
|
||||
38
Task/Web-scraping/QB64/web-scraping.qb64
Normal file
38
Task/Web-scraping/QB64/web-scraping.qb64
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
' Assuming WGET is installed
|
||||
Dim sContent$, sUTC$, sRFC850$, tmpFile$, cmd$, linea$
|
||||
|
||||
tmpFile$ = Environ$("TEMP") + "\utctime.html"
|
||||
cmd$ = "wget -q -O " + tmpFile$ + " https://www.utctime.net"
|
||||
|
||||
Print "Download with wget..."
|
||||
Shell _Hide cmd$
|
||||
|
||||
' Read file
|
||||
If _FileExists(tmpFile$) Then
|
||||
Open tmpFile$ For Input As #1
|
||||
sContent$ = ""
|
||||
While Not EOF(1)
|
||||
Line Input #1, linea$
|
||||
sContent$ = sContent$ + linea$ + Chr$(10)
|
||||
Wend
|
||||
Close #1
|
||||
Kill tmpFile$
|
||||
End If
|
||||
|
||||
' Extract UTC and RFC 850
|
||||
utcStart = InStr(sContent$, "UTC</td><td>")
|
||||
If utcStart > 0 Then
|
||||
utcStart = utcStart + 12
|
||||
utcEnd = InStr(utcStart, sContent$, "</td>")
|
||||
If utcEnd > 0 Then sUTC$ = RTrim$(Mid$(sContent$, utcStart, utcEnd - utcStart))
|
||||
End If
|
||||
|
||||
rfcStart = InStr(sContent$, "RFC 850</td><td>")
|
||||
If rfcStart > 0 Then
|
||||
rfcStart = rfcStart + 16
|
||||
rfcEnd = InStr(rfcStart, sContent$, "</td>")
|
||||
If rfcEnd > 0 Then sRFC850$ = RTrim$(Mid$(sContent$, rfcStart, rfcEnd - rfcStart))
|
||||
End If
|
||||
|
||||
Print "UTC: "; sUTC$
|
||||
Print "RFC 850: "; sRFC850$
|
||||
30
Task/Web-scraping/REXX/web-scraping.rexx
Normal file
30
Task/Web-scraping/REXX/web-scraping.rexx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
-- 23 Oct 2025
|
||||
include Setting
|
||||
signal off notready
|
||||
|
||||
say 'WEB SCRAPING'
|
||||
say version
|
||||
say
|
||||
call Task
|
||||
exit
|
||||
|
||||
Task:
|
||||
procedure
|
||||
-- Get page from web (curl is pre-installed on Windows 10/11, Unix and MacOS)
|
||||
out='Web.html'
|
||||
'curl https://rosettacode.org/wiki/Talk:Web_scraping --ssl-no-revoke --silent --output' out
|
||||
-- Read file
|
||||
file=Charin(out,1,100000)
|
||||
-- Extract all time stamps
|
||||
p=Pos('(UTC)',file)
|
||||
do while p>0
|
||||
p2=p-2
|
||||
do p1=p2 by -1 until Substr(file,p1,1)=':'
|
||||
end
|
||||
p1-=2
|
||||
say Substr(file,p1,p2-p1+1)
|
||||
p=Pos('(UTC)',file,p+1)
|
||||
end
|
||||
return
|
||||
|
||||
include Abend
|
||||
25
Task/Web-scraping/Rebol/web-scraping.rebol
Normal file
25
Task/Web-scraping/Rebol/web-scraping.rebol
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Rebol [
|
||||
Title: "Web Scraping"
|
||||
URL: http://rosettacode.org/wiki/Web_Scraping
|
||||
]
|
||||
|
||||
; Notice that REBOL understands unquoted URL's:
|
||||
|
||||
service: http://tycho.usno.navy.mil/cgi-bin/timer.pl
|
||||
|
||||
; The 'read' function can read from any data scheme that REBOL knows
|
||||
; about, which includes web URLs. NOTE: Depending on your security
|
||||
; settings, REBOL may ask you for permission to contact the service.
|
||||
|
||||
html: read service
|
||||
|
||||
; I parse the HTML to find the first <br> (note the unquoted HTML tag
|
||||
; -- REBOL understands those too), then copy the current time from
|
||||
; there to the "UTC" terminator.
|
||||
|
||||
; I have the "to end" in the parse rule so the parse will succeed.
|
||||
; Not strictly necessary once I've got the time, but good practice.
|
||||
|
||||
parse html [thru <br> copy current thru "UTC" to end]
|
||||
|
||||
print ["Current UTC time:" current]
|
||||
30
Task/Web-scraping/VBScript/web-scraping.vbs
Normal file
30
Task/Web-scraping/VBScript/web-scraping.vbs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
Function GetUTC() As String
|
||||
Url = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
|
||||
With CreateObject("MSXML2.XMLHTTP.6.0")
|
||||
.Open "GET", Url, False
|
||||
.send
|
||||
arrt = Split(.responseText, vbLf)
|
||||
End With
|
||||
For Each t In arrt
|
||||
If InStr(t, "UTC") Then
|
||||
GetUTC = StripHttpTags(t)
|
||||
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End Function
|
||||
|
||||
Function StripHttpTags(s)
|
||||
With New RegExp
|
||||
.Global = True
|
||||
.Pattern = "\<.+?\>"
|
||||
If .Test(s) Then
|
||||
StripHttpTags = .Replace(s, "")
|
||||
Else
|
||||
StripHttpTags = s
|
||||
End If
|
||||
End With
|
||||
End Function
|
||||
|
||||
WScript.StdOut.Write GetUTC
|
||||
WScript.StdOut.WriteLine
|
||||
3
Task/Web-scraping/Yabasic/web-scraping-1.basic
Normal file
3
Task/Web-scraping/Yabasic/web-scraping-1.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
cd /d c:\Yabasic
|
||||
wget -q -O utctime.html https://www.utctime.net
|
||||
yabasic webscraping.yab
|
||||
25
Task/Web-scraping/Yabasic/web-scraping-2.basic
Normal file
25
Task/Web-scraping/Yabasic/web-scraping-2.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Read file line by line
|
||||
open "utctime.html" for reading as #1
|
||||
sContent$ = ""
|
||||
while not eof(1)
|
||||
line input #1 linea$
|
||||
sContent$ = sContent$ + linea$ + chr$(10)
|
||||
wend
|
||||
close #1
|
||||
|
||||
utcStart = instr(sContent$, "UTC</td><td>")
|
||||
if utcStart > 0 then
|
||||
utcStart = utcStart + 12
|
||||
utcEnd = instr(sContent$, "</td>", utcStart)
|
||||
if utcEnd > 0 sUTC$ = trim$(mid$(sContent$, utcStart, utcEnd - utcStart))
|
||||
end if
|
||||
|
||||
rfcStart = instr(sContent$, "RFC 850</td><td>")
|
||||
if rfcStart > 0 then
|
||||
rfcStart = rfcStart + 16
|
||||
rfcEnd = instr(sContent$, "</td>", rfcStart)
|
||||
if rfcEnd > 0 sRFC850$ = trim$(mid$(sContent$, rfcStart, rfcEnd - rfcStart))
|
||||
end if
|
||||
|
||||
print "UTC: ", sUTC$
|
||||
print "RFC 850: ", sRFC850$
|
||||
Loading…
Add table
Add a link
Reference in a new issue