Moderatori: Anthony47, Triumph Of Steel, archimede
curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%2C12.50&text=Ascii&start=latest" -o file.txt
Anthony47 ha scritto:Puoi fare un esempio di come si varia l'Ora, perche' a me appena vario Giorno oppure Ora rispetto a quanto mi propone all'apertura della pagina https://rucsoundings.noaa.gov/ non restituisce piu' nessuna tabella
Anthony47 ha scritto:Dovresti essere anche un po' piu' preciso quando dici "bisognerebbe scegliere 1 ora specifica ed il file relativo andrebbe scritto sempre in un file.txt specifico": intendi "scegliere a mano nell'interfaccia della pagina" o come, e che relazione c'e' tra la scelta e il file.txt specifico?
(ma quel sito e' all'interno del Museo dell'Aviazione?)
Dylan666 ha scritto:Hai complicato una cosa molto semplice.
Come spiega il link "parameters for text requests" di quella stessa pagina tutte le opzioni che metti a mano nel form non fanno altro che comporre l'URL della pagina che ti apparirà successivamente.
Se quindi mettendo le voci come dici tu ottieni questa stringa...
https://rucsoundings.noaa.gov/get_sound ... art=latest
...basterà ri-utilizzare direttamente questo indirizzo o modificarlo lievemente senza dove passare ogni volta da interfaccia grafica e click pre-registrati
Dylan666 ha scritto:Ecco la corrispondenza tra i tuoi step e le parti dell'URL
1 - Aprire l'url
2- Selezionare il pallino GFS
3 -Immettere il valore 44.00,12.50 (scritto 44punto00virgola12punto50) nella casella in basso Site(s)
4 -Clicare su analyses (di fianco a Desidered forecast projection)
5-Cliccare nella casella in basso "Ascii text (GLS format)
https://rucsoundings.noaa.gov/get_sound ... ta_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%2C12.50&text=Ascii&start=latest
Dylan666 ha scritto:Quindi poi ti basta un file batch che usi CURL o WGET per scaricare la pagina.
Nel caso del primo basta dare
- Codice: Seleziona tutto
curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%2C12.50&text=Ascii&start=latest" -o file.txt
Lo prendi qui:
https://curl.se/windows/
Dylan666 ha scritto:Poi vedremo come "pulire" il file.
Se ti sai usare PowerShell il comando Wget dovresti ritrovartelo come già riconosciuto
CD %~dp0
curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%2C12.50&text=Ascii&start=latest" -o "RS GFS analisi.txt"
CD %~dp0
curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "RS GFS analisi.txt"
Sub NoaaImport()
Dim RTxt As String, mySplit
Dim FreeF, cTxtFile, I As Long
Dim XMLObj As Object
'
Set XMLObj = CreateObject("msxml2.xmlhttp")
Debug.Print "Ready --->"
For I = 1 To 10
If Len(Range("B5").Cells(I, 1)) < 3 Then Exit For
myUrl = Range("C5").Cells(I, 1).Value
With XMLObj
.Open "GET", myUrl, False
.send
RTxt = .responseText
End With
mySplit = Split(RTxt & " " & "kt" & Chr(10) & "..VUOTO. ", "kt", , vbTextCompare)
'
FreeF = FreeFile
cTxtFile = Range("B1") & Range("B5").Cells(I, 1).Value
Debug.Print cTxtFile, "I=" & I, Len(RTxt), Left(mySplit(1), 50)
Open cTxtFile For Append As #FreeF
Print #FreeF, Format(Now, "dd-mmm-yy hh:mm") '********** SOLO DEBUG?
Print #FreeF, Replace(mySplit(1), Chr(34), "", , , vbTextCompare)
Close #FreeF
Next I
Set XMLObj = Nothing
MsgBox ("Importati N° " & I - 1 & " file")
End Sub
ECHO off
CD %~dp0
DEL "RS GFS analisi.txt"
curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS analisi.txt"
)
)
)
DEL file_temporaneo.txt
Anthony47 ha scritto:Una possibile alternativa a quanto ti sta insegnando Dylan, basata su excel + vba e XML requests, come dimostrato nel file scaricabile da qui: https://www.dropbox.com/scl/fi/mshsfd3y ... ra486&dl=0
Il layout del foglio:
-Nelle aree in giallo vanno inseriti: in colonna A il parametro da selezionare e in colonna B il nome del file (max 10 combinazioni). I file indicati devono gia' esistere nella directory specificata.
-Nell'area in arancione e' presente una formula che codifica l'url della richiesta da inoltrare, basandosi su parametri inseriti in altre celle.
-Ipoteticamente in A3:B4 si possono inserire i parametri di altri siti di cui chiedere i dati
La macro associata al pulsante:
- Codice: Seleziona tutto
Sub NoaaImport()
Dim RTxt As String, mySplit
Dim FreeF, cTxtFile, I As Long
Dim XMLObj As Object
'
Set XMLObj = CreateObject("msxml2.xmlhttp")
Debug.Print "Ready --->"
For I = 1 To 10
If Len(Range("B5").Cells(I, 1)) < 3 Then Exit For
myUrl = Range("C5").Cells(I, 1).Value
With XMLObj
.Open "GET", myUrl, False
.send
RTxt = .responseText
End With
mySplit = Split(RTxt & " " & "kt" & Chr(10) & "..VUOTO. ", "kt", , vbTextCompare)
'
FreeF = FreeFile
cTxtFile = Range("B1") & Range("B5").Cells(I, 1).Value
Debug.Print cTxtFile, "I=" & I, Len(RTxt), Left(mySplit(1), 50)
Open cTxtFile For Append As #FreeF
Print #FreeF, Format(Now, "dd-mmm-yy hh:mm") '********** SOLO DEBUG?
Print #FreeF, Replace(mySplit(1), Chr(34), "", , , vbTextCompare)
Close #FreeF
Next I
Set XMLObj = Nothing
MsgBox ("Importati N° " & I - 1 & " file")
End Sub
A fine macro un msgbox avverte del completamento
Al momento, la macro inserisce prima del blocco desiderato Data e ora dell'importazione; a me e' servita per debug, se a te da fastidio devi allora eliminare la riga marcata "********** SOLO DEBUG?"
Prova...
ECHO off
CD %~dp0
DEL "RS GFS Analisi.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=analyses&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS Analisi.txt"
)
)
)
DEL file_temporaneo.txt
REM +06
DEL "RS GFS +06.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=06&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+06.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+06.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +06.txt"
)
)
)
DEL file_temporaneo+06.txt
REM +12
DEL "RS GFS +12.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=12&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+12.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+12.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +12.txt"
)
)
)
DEL file_temporaneo+12.txt
REM +18
DEL "RS GFS +18.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=18&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+18.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+18.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +18.txt"
)
)
)
DEL file_temporaneo+18.txt
REM +24
DEL "RS GFS +24.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=24&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+24.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+24.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +24.txt"
)
)
)
DEL file_temporaneo+24.txt
REM +48
DEL "RS GFS +48.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=48&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+48.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+48.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +48.txt"
)
)
)
DEL file_temporaneo+48.txt
REM +60
DEL "RS GFS +60.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=60&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+60.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+60.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +60.txt"
)
)
)
DEL file_temporaneo+60.txt
REM +72
DEL "RS GFS +72.txt"
.\curl "https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&latest=latest&start_year=2024&start_month_name=Jan&start_mday=23&start_hour=9&start_min=0&n_hrs=1.0&fcst_len=72&airport=44.00%%2C12.50&text=Ascii&start=latest" -o "file_temporaneo+72.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A LineCount=0
FOR /F "delims=" %%a IN (file_temporaneo+72.txt) DO (
SET /A LineCount+=1
IF !LineCount! GEQ 7 (
IF !LineCount! LEQ 19 (
ECHO %%a>>"RS GFS +72.txt"
)
)
)
DEL file_temporaneo+72.txt
MOVE *.TXT "E:\Meteorologia\Software meteo\Wetbulb in quota\"
File batch per copiare file selezionato da menu contestuale Autore: valle1975 |
Forum: Programmazione Risposte: 3 |
Perchè l'importazione dati con Selenium non fuziona? Autore: aggittoriu |
Forum: Applicazioni Office Windows Risposte: 7 |
copia di dati da un file chiuso e elaborazione Autore: luca62 |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 11 ospiti