I have a script that is pretty straight forward, open a website with an https socket and copy the output into a file, my problem is, i am getting a 400 error when the socket opens and i need to really copy a line that starts with a string, say TTNM7 to a variable so that it can be processed later.
Alias Demo {
/remove c:\aprs\ $+ $date(mm) $+ $date(dd) $+ .txt
sockOpen -e demo mesonet.agron.iastate.edu 443
}
;https://mesonet.agron.iastate.edu/request/coop/obs-dl.php?network=MO_COOP&station%5B%5D=TTNM7&year1= 4+ $date(yyyy) $+ &month1=12&day1=23&year2=2024&month2=12&day2=23&what=view&delim=space
on *:SockOpen:demo: {
sockwrite -nt demo GET request/coop/obs-dl.php?network=MO_COOP&station%5B%5D=TTNM7&year1= $+ $date(yyyy) $+ &month1= $+ $date(mm) $+ &day1= $+ $date(dd) $+ &year2= $+ $date(yyyy) $+ &month2= $+ $date(mm) $+ &day2= $+ $date(dd) $+ &what=view&delim=space HTTP/1.1
echo request/coop/obs-dl.php?network=MO_COOP&station%5B%5D=TTNM7&year1= $+ $date(yyyy) $+ &month1= $+ $date(mm) $+ &day1= $+ $date(dd) $+ &year2= $+ $date(yyyy) $+ &month2= $+ $date(mm) $+ &day2= $+ $date(dd) $+ &what=view&delim=space HTTP/1.0
sockwrite -nt demo Host: 204.48.104.102
sockwrite -nt demo $crlf
}
on *:SockRead:demo: {
var %read
sockRead -t %read
echo %read
if (TTNM7 isin %read) {
write c:\aprs\ $+ $date(mm) $+ $date(dd) $+ .txt $1-
}
}
on *:SockClose:demo: {
set %tx-sec $round($calc(%tx-time / 1000),0)
set %tx-min $calc(%tx-sec / 60)
/timerdemo 23:58 1 1 /demo
}
it outputs..
HTTP/1.1 400 Bad Request
Date: Tue, 24 Dec 2024 15:59:14 GMT
Server: Apache/2.4.62 (Rocky Linux) OpenSSL/3.4.0 mod_fcgid/2.3.9 mod_wsgi/5.0.0 Python/3.11
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
anyone have any ideas what i am doing wrong?