Re: [PD] webpage to xml

2016-04-04 Thread Csaba Láng
Thanks, gentlemen for the prompt and proper answer.
Python is a good approach, but a pure PD solution is always the most
welcome.

Updates with some results are coming soon.

Best:

Popesz


On Mon, Apr 4, 2016 at 12:17 PM, IOhannes m zmoelnig 
wrote:

> On 2016-04-02 12:12, Csaba Láng wrote:
> > Dear list,
> >
> > is there any option to convert automatically webpage content to xml in
> PD?
> > I would like to create some interactive installations based on web
> content,
> > and still looking for a simple way.
> >
>
> how do you convert webpage content to XML in *any language*?
>
> attached is a very simplistic example, exploiting the underspecification
> of your problem space.
>
> the patch uses mrpeach/net and mrpeach/binfile to demonstration purposes
> (fetching the HTML from a live website, saving the XML to a file), but
> the actual "conversion" is done in Pd-vanilla.
>
> i haven't tested it excessively, but the conversion i did test (the one
> encoded into the example patch) validates as correct XML.
>
> gfmasdr
> IOhannes
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] webpage to xml

2016-04-04 Thread IOhannes m zmoelnig
On 2016-04-02 12:12, Csaba Láng wrote:
> Dear list,
> 
> is there any option to convert automatically webpage content to xml in PD?
> I would like to create some interactive installations based on web content,
> and still looking for a simple way.
> 

how do you convert webpage content to XML in *any language*?

attached is a very simplistic example, exploiting the underspecification
of your problem space.

the patch uses mrpeach/net and mrpeach/binfile to demonstration purposes
(fetching the HTML from a live website, saving the XML to a file), but
the actual "conversion" is done in Pd-vanilla.

i haven't tested it excessively, but the conversion i did test (the one
encoded into the example patch) validates as correct XML.

gfmasdr
IOhannes
#N canvas 529 48 712 894 10;
#X obj 119 146 httpreq;
#X obj 138 309 unpack 0 0 0 0;
#X floatatom 138 332 3 0 0 0 - - -, f 3;
#X floatatom 165 332 3 0 0 0 - - -, f 3;
#X floatatom 192 332 3 0 0 0 - - -, f 3;
#X floatatom 219 332 3 0 0 0 - - -, f 3;
#X obj 119 257 tcpclient;
#X obj 155 283 tgl 15 0 empty empty connected 18 7 0 8 -24198 -13381
-1 0 1;
#X obj 119 450 httpreceive;
#X floatatom 182 483 5 0 0 0 - - -, f 5;
#X obj 17 308 tgl 15 0 empty empty empty 17 7 0 10 -4034 -257985 -1
0 1;
#X msg 295 89 GET http://puredata.info/;
#X msg 295 23 connect puredata.info 80;
#N canvas 434 116 882 468 HTML2XML 1;
#X obj 64 39 inlet;
#X obj 64 161 list prepend XML-header;
#X obj 64 233 list append XML-footer, f 28;
#X obj 222 31 loadbang;
#X msg 222 74 60 63 120 109 108 32 118 101 114 115 105 111 110 61 34
49 46 48 34 32 101 110 99 111 100 105 110 103 61 34 85 84 70 45 56
34 63 62 10 60 104 116 109 108 45 99 111 100 101 62 10 60 33 91 67
68 65 84 65 91 10;
#X msg 254 199 93 93 62 10 60 47 104 116 109 108 45 99 111 100 101
62 10;
#X obj 222 53 t b b;
#X obj 64 255 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 7 0;
#X connect 3 0 6 0;
#X connect 4 0 1 1;
#X connect 5 0 2 1;
#X connect 6 0 4 0;
#X connect 6 1 5 0;
#X restore 119 580 pd HTML2XML;
#X obj 199 652 binfile;
#X obj 119 602 t a a;
#X obj 119 734 spigot 0;
#X obj 119 756 print XML;
#X obj 327 715 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 273 599 write html.xml \, clear;
#X obj 146 628 list split 10;
#X obj 146 650 print;
#X connect 0 0 6 0;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X connect 1 2 4 0;
#X connect 1 3 5 0;
#X connect 6 0 8 0;
#X connect 6 1 1 0;
#X connect 6 2 7 0;
#X connect 8 0 13 0;
#X connect 8 2 9 0;
#X connect 11 0 0 0;
#X connect 12 0 6 0;
#X connect 13 0 15 0;
#X connect 15 0 16 0;
#X connect 15 1 20 0;
#X connect 15 1 14 0;
#X connect 16 0 17 0;
#X connect 18 0 16 1;
#X connect 19 0 14 0;
#X connect 20 0 21 0;


signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] webpage to xml

2016-04-03 Thread Thomas Mayer
HI,

On 02.04.2016 12:12, Csaba Láng wrote:
> Dear list,
> 
> is there any option to convert automatically webpage content to xml in PD?
> I would like to create some interactive installations based on web
> content, and still looking for a simple way.

Converting a symbol into XML or DOM is not possible with Pd, but you
could write your parser in a seperate program, e.g. using Python and
Beautiful Soup (https://pypi.python.org/pypi/beautifulsoup4).

Then you can send the data to Pd using UDP and [netreceive] in Pd.

If you can control the webserver, you could output the data as JSON and
then use my extension PuREST JSON:
http://ix.residuum.org/pd/purest_json.html

Hth,
Thomas
-- 
"From the perspective of communication analysis, government is not
an instrument of law and order, but of law and disorder." (Gracchus
Gruad in: Robert Shea & Robert A. Wilson, The Golden Apple)
http://www.residuum.org/

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list