I'm trying to get netclient to download an xml file from my subscription at weather.com but a strange thing happened. I try to send a fairly long GET message (containing a search string, a few parameters and ID+password), and it seems to work on a regular browser but not in PD. When I connect the message box containing the GET message to a print object it doesn't print the whole string in the console, it seems like there's a limit on either the message box(how many characters it can send) or the print object(in which case I'm probably chasing the wrong problem altogether). I've attached the test patch but the user ID and the password is false so if anyone tries it out they will probably get an error page sent back(but then at least the query works). I hope I'm explaining this clearly enough... Is there a workaround to this problem, or have I just done something wrong?
Halloween Humour: Why is it so difficult to become a coroner?
http://
Rune Lain Knudsen wrote:
I'm trying to get netclient to download an xml file from my subscription at weather.com but a strange thing happened. I try to send a fairly long GET message (containing a search string, a few parameters and ID+password), and it seems to work on a regular browser but not in PD. When I connect the message box containing the GET message to a print object it doesn't print the whole string in the console, it seems like there's a limit on either the message box(how many characters it can send) or the print object(in which case I'm probably chasing the wrong problem altogether). I've attached the test patch but the user ID and the password is false so if anyone tries it out they will probably get an error page sent back(but then at least the query works). I hope I'm explaining this clearly enough... Is there a workaround to this problem, or have I just done something wrong?
It seemed to me that using pd to parse xml is like using a screwdriver to hammer nails so I did it using awk, since awk is very simple and efficient at parsing and can also communicate via tcp/ip. Here I access a weather site and extract the relevant data in an awk script which it sends to a [netreceive] in pd whenever the pd patch requests it. I'm running awk in a Cygwin terminal in WinXP and pd 0.37.1. Martin
#N canvas 0 1 619 491 10; #X obj 45 213 netsend; #X msg 26 4 connect localhost 8888; #X msg 14 187 disconnect; #X msg 91 187 send hello $1; #X obj 74 86 counter; #X floatatom 91 113 5 0 0 0 - - -; #X obj 40 24 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X floatatom 352 166 5 0 0 0 - - -; #X obj 234 134 netreceive 8887; #X text 233 113 run ./get_weather.awk in a cygwin terminal for this to work; #X obj 232 244 vsl 15 128 -40 40 0 0 empty empty empty 0 -8 0 8 -258699 -241291 -44926 10160 1; #X text 385 165 connections; #X obj 232 221 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 24 256; #X obj 289 221 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 102 256; #X obj 234 201 unpack 1 1; #X obj 289 244 vsl 15 128 0 127 0 0 empty empty empty 0 -8 0 8 -62784 -241291 -258699 10200 1; #X obj 245 166 print >; #X text 234 100 Montreal current temperature & pressure; #X text 194 373 degrees C; #X text 291 373 kPa; #X obj 41 48 metro 60000; #X text 116 40 once a minute , even though the site updates about once an hour....; #X text 176 4 once get_weather.awk is running , hit connect; #X text 61 24 trigger a message; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 3 0 0 0; #X connect 4 0 5 0; #X connect 5 0 3 0; #X connect 6 0 20 0; #X connect 8 0 14 0; #X connect 8 0 16 0; #X connect 8 1 7 0; #X connect 12 0 10 0; #X connect 13 0 15 0; #X connect 14 0 12 0; #X connect 14 1 13 0; #X connect 20 0 4 0;
#!/bin/awk -f
# based on http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html#GETURL
# Gets an html text weather report for Montreal, extracts the current temperature in degrees Celsius
# and pressure in kiloPascals.
# Waits for some message from pd on tcp port 8888.
# When it gets a message, it GETs the URL and parses it for the current temperature and pressure.
# Then it sends the numbers to pd on tcp port 8887
# See pd_server_awk_tester.pd
BEGIN { Host = "text.weatheroffice.ec.gc.ca" URL = "http://text.weatheroffice.ec.gc.ca/forecast/city_e.html?qc-147&unit=m" Port = 80 Method = "GET" HttpService = "/inet/tcp/0/" Host "/" Port do { RS = "\n" "/inet/tcp/8888/0/0" |& getline ORS = RS = "\r\n\r\n" print Method " " URL " HTTP/1.0" |& HttpService HttpService |& getline Header # print Header > "/dev/stderr" RS = "<dt>" while ((HttpService |& getline) > 0) { if ($0 ~ "Temperature" ) { temp = "Temperature" $2 $3 } if ($0 ~ "Pressure" ) { press = "Pressure" $2 $3 } } close(HttpService) split(temp, a, "<dd>") split (a[2], b, "&") split(press, c, "<dd>") split (c[2], d, "&") output = b[1]" "d[1] ";" print output # Use [netreceive 8899] in PD. Note that the semicolon must be present # or the message will not come out of netreceive. print output |& "/inet/tcp/0/localhost/8887/" } while (1) # well we never get here but: close("/inet/tcp/0/localhost/8887") close("/inet/tcp/8888/0/0") }
Quoting Martin Peach martinrp@vax2.concordia.ca:
Rune Lain Knudsen wrote:
I'm trying to get netclient to download an xml file from my
subscription at weather.com but a strange thing happened. I try to send a fairly long GET message (containing a search string, a few parameters and ID+password), and it seems to work on a regular browser but not in PD. When I connect the message box containing the GET message to a print object it doesn't print the whole string in the console, it seems like there's a limit on either the message box(how many characters it can send) or the print object(in which case I'm probably chasing the wrong problem altogether).
there is definitely i limit in [print]; there might be a limit in the symbol-length but i never found one (the longest symbol i ever made was some 20.000 chars long)
i'm not really sure whether there is a limit in the message-box, but i guess as long as you don't need to save the content of the message-box (by saving the patch) you should be fine.
mfg.ads.r IOhannes
hi pd-list
I wondered if you've successfully sent a GET with netclient and
received something . I'd like to communicate with a php script this way
. Despite all my effort I never received any data from a server .
I tried Rune Lain Knudsen's WeatherTest1.pd : http://lists.puredata.info/pipermail/pd-list/2005-09/030918.html
connecting to port 80
print: send GET
http://xoap.weather.com/search/local/NOXX0029?
cc=*prod=xoap&par=151y032476&key*
netclient: connection closed on socket 9
or (endless output)
netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected (I don't know how this could happen but it wasn't the first time)
I'm on os x , pd (037 - 039) , maxlib 1.5.2
thanks a lot for any hint . enrique
[connect xoap.weather.com 80(
|
| [send GET
http://xoap.weather.com/search/local/NOXX0029?
cc=*prod=xoap&par=151y032476&key=876717583u446bae(
| /
[netclient]
|
[print]
Enrique Erne wrote:
hi pd-list
I wondered if you've successfully sent a GET with netclient and
received something . I'd like to communicate with a php script this way
. Despite all my effort I never received any data from a server .I tried Rune Lain Knudsen's WeatherTest1.pd : http://lists.puredata.info/pipermail/pd-list/2005-09/030918.html
connecting to port 80 print: send GET http://xoap.weather.com/search/local/NOXX0029? cc=*prod=xoap&par=151y032476&key* netclient: connection closed on socket 9
hmm, i think that this is rather a problem with the protocol. when i open a telnet session to xoap.weather.com and request the same GET, the server will close the connection too.
try sending something like: "GET /search/local/NOXX0029 HTTP/1.0 "
(which gives me a redirect to another site)
or (endless output)
netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected (I don't know how this could happen but it wasn't the first time)
after the server closes the connection (and http-servers tend to close connections after each request), [netclient] is not connected any more - you have to reconnect.
mfg.ad.r IOhannes
hi eni
i thinks its no way that you can make HTTP GET-requests with pd. i don't know if the server may skip this, but [netclient] puts an ';' after each line. further is a correct GET request followed by two 'new line'-charactrers. if you put these in your message-box, they are skipped by [netclient]. for a short overview over the http-protocol and the syntax of GET, see: http://en.wikipedia.org/wiki/HTTP
if you send:
|send GET index.html HTTP/1.1 / | | |_____________________________\
to telenet on localhost, you get 'GET index.html HTTP/1.1;' wich is not a valid GET-request.
suddenly the example-address you posted, didn't even work with telnet. i would test with telnet first. it seems that some server want more info in order make them send the requested page.
roman
"Enrique Erne" wrote:
hi pd-list
I wondered if you've successfully sent a GET with netclient and received something . I'd like to communicate with a php script this
way
. Despite all my effort I never received any data from a server .
I tried Rune Lain Knudsen's WeatherTest1.pd : http://lists.puredata.info/pipermail/pd-list/2005-09/030918.html
connecting to port 80 print: send GET http://xoap.weather.com/search/local/NOXX0029? cc=*prod=xoap&par=151y032476&key* netclient: connection closed on socket 9
or (endless output)
netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected netclient: not connected (I don't know how this could happen but it wasn't the first time)
I'm on os x , pd (037 - 039) , maxlib 1.5.2
thanks a lot for any hint . enrique
___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
On Tue, Sep 13, 2005 at 04:26:36PM +0200, Roman Haefeli wrote:
hi eni
i thinks its no way that you can make HTTP GET-requests with pd
why not? with python:
import urllib data = urllib.urlopen('http://www.blahblah/%27).read() (pyext output crap here)
hi carmen
you're right. i wanted to say, that it is may not possible in pd itself (or is it?), since i know enrique and that he rather not uses pd with another script-language.
cheers
"carmen" wrote:
On Tue, Sep 13, 2005 at 04:26:36PM +0200, Roman Haefeli wrote:
hi eni
i thinks its no way that you can make HTTP GET-requests with pd
why not? with python:
import urllib data = urllib.urlopen('http://www.blahblah/%27).read() (pyext output crap here)
___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
Hi all,
Yes, I would go with the pyext or shell way. (wget, curl, etc...) By the way, here is a PHP class to send data to Pd through UDP. Just in case it might be useful. You will need to remove the help part at the end of it to use it in your own page, and then just include it. There is an example patch, using netreceive.
Enjoy ! Don't hesitate to send me comments.
Alexandre Quessy http://www.sourcelibre.com/puredata/
Le 05-09-13, à 11:14, Roman Haefeli a écrit :
hi carmen
you're right. i wanted to say, that it is may not possible in pd itself (or is it?), since i know enrique and that he rather not uses pd with another script-language.
cheers
"carmen" wrote:
On Tue, Sep 13, 2005 at 04:26:36PM +0200, Roman Haefeli wrote:
hi eni
i thinks its no way that you can make HTTP GET-requests with pd
why not? with python:
import urllib data = urllib.urlopen('http://www.blahblah/%27).read() (pyext output crap here)
___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
hi all
actually I could receive a little HTML in a server error . I tried to use the ; to make a backslash entity . #092; %3B#092 (maybe a very bad hack)
[connect 195.176.254.176 80( | | [send GET /index.php HTTP/1.1 %3B( | | | | [disconnect( | | / [netclient] | [print]
output was:
connecting to port 80 print: was not found on this server.<P> <HR> <ADDRESS>Apache/1.3.33 Server at 195.176.254.176 Port 80</ADDRESS> </BODY></HTML> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL /index.php HTTP/1.1 netclient: connection closed on socket 8
that was not too bad , wasn't it ? If I'm not wrong it's just
a problem with the protocol.
I might write a HTTP-mailing-list . does somebody know one ?
next time I start from the begin with shell , install phyton ... ... or osc?
good night from the end of the world. eni
hello,
I'm new in PD univers.... I'm trying to read the date from the bios.
How can I do?
Thank you
Ben
date from zexy.
cyrille
RAOULT Benoît a écrit :
hello,
I'm new in PD univers.... I'm trying to read the date from the bios.
How can I do?
Thank you
Ben
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list