Posted: 05:22pm 13 Aug 2023 |
Copy link to clipboard |
Print this post |
|
Hello experts,
I have tried to read data from a web page with the PicoW. Unfortunately it did not work. Then I tried to use the GET request block of my FireFox. But it is longer than a string allows.
WEB TCP CLIENT REQUEST query$, inbuf [, timeout] Longstring does not work as parameter for query$.
Also parts of the block did not work.
I always get the Bad Request error message.
Here is the program and the result:
' HTTP Client
Dim buff%(8000)
If MM.Info(ip address) = "0.0.0.0" Then Print "Kein WLAN ... Neustart ... " CPU restart EndIf
WEB ntp +2, "fritz.box" ' Germany = +2 hours summer time
Print "Connected to W-Lant ... "
Dim Query$ = "GET /index.html HTTP/1.1"+Chr$(10)+Chr$(13) Query$ = Query$ +"Host: www.thebackshed.com"+Chr$(10)+Chr$(13) Query$ = Query$ +"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64;" Query$ = Query$ +" rv:109.0) Gecko/20100101 Firefox/111.0"+Chr$(10)+Chr$(13) Query$ = Query$ +"Accept: text/html"+Chr$(10)+Chr$(13) Query$ = Query$ +"Accept-Language: de,en-US"+Chr$(10)+Chr$(13) Query$ = Query$ +"Accept-Encoding: gzip, deflate"+Chr$(10)+Chr$(13) Query$ = Query$ +"Connection: keep-alive"+Chr$(10)+Chr$(13) Query$ = Query$ +Chr$(10)+Chr$(13) Print :Print "Query$:" Print Query$ Print "End of Query$":Print
WEB OPEN TCP CLIENT "www.thebackshed.com", 80 WEB TCP CLIENT REQUEST Query$, buff%() WEB CLOSE TCP CLIENT Print "Recived Buffer:" LongString Print buff%() Print "End of Rrecived Buffer"
> RUN ntp address 192.168.20.1 got ntp response: 13/08/2023 18:51:38 Connected to W-Lant ...
Query$: GET /index.html HTTP/1.1 Host: www.thebackshed.com User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0 Accept: text/html Accept-Language: de,en-US Accept-Encoding: gzip, deflate Connection: keep-alive
End of Query$
tcp address 208.87.135.105 Connected Recived Buffer: HTTP/1.1 400 Bad Request Date: Sun, 13 Aug 2023 16:51:39 GMT Server: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k 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>
End of Rrecived Buffer >
The Optionlist:
> option list WebMite MMBasic Version 5.07.07 OPTION COLOURCODE ON OPTION WIFI Jathe, **************** >
Can anyone help? |