parsing simple HTML

Aug 2, 2011 at 12:21pm

parsing simple HTML

hello forum,

i am trying to parse a simple HTML document generated on an arduino with a serial shield. the HTML is super simple: it contains the state of three buttons, each with the prefix “B1:”,”B2:” or “B3:”, followed by either ’1′ or ’0′ depending on the button state.

so when the arduino IP is typed in on a standard browser this is what loads:

B1:1 B2:1 B3:1

i know i can parse with ‘regexp’, but i really dont get the perl syntax at all :( so i was hoping someone could help me parse this. thanks!

below is what i got so far:

– Pasted Max Patch, click to expand. –
#58313
Aug 3, 2011 at 12:04pm

please help. i am stuck.

as i am defining the webserver side i can make the arduino make a simple comma seperated list, 3 bytes even. i am just very unfamiliar with max and handling string / documente in this environment that i really don’t know how to progress…

what i tried now is to make a website that only contains the 3 0/1s seperated by spaces. i can sort a simple message, say “1 0 1″ the way i would like to sort the HTML download. but i can’t pass jit.textfile to the ‘unpack’ object. at least it gives no result.

– Pasted Max Patch, click to expand. –
#209499
Aug 3, 2011 at 1:02pm

About jit.uldl and regexp, search the forum and look for Luke Hall !

With Arduino and multiple sensors, I use a letter + the analog number (a10, b50, …). It’s simple and works well. Here is the regexp for this.

– Pasted Max Patch, click to expand. –
#209500
Aug 3, 2011 at 9:34pm

If the HTML ends up looking like the example I’ve included in the comment box then the following patch should work for you. If not then it would be helpful if you gave us an idea of the exact HTML content the page will be delivering.

– Pasted Max Patch, click to expand. –
#209501
Aug 4, 2011 at 7:18am

thanks for the help!
sorry for not including the website, i can see how that would have clarified things.
strange thing is, this still doesn’t work for me. even when making a website which matches your example HTML in the comment field exactly? when double clicking ‘jit.textfile’ i can see the file gets downloaded correctly….?

the max window gives me:
fromsymbol: doesn’t understand “int”
flonum: doesn’t understand “B”
fromsymbol: doesn’t understand “int”
fromsymbol: doesn’t understand “float”

i put the HTML here: http://mikrogalleriet.net/test/arduino_website.html

#209502
Aug 4, 2011 at 7:18am

thanks for the help!
sorry for not including the website, i can see how that would have clarified things.
strange thing is, this still doesn’t work for me. even when making a website which matches your example HTML in the comment field exactly? when double clicking ‘jit.textfile’ i can see the file gets downloaded correctly….?

the max window gives me:
fromsymbol: doesn’t understand “int”
flonum: doesn’t understand “B”
fromsymbol: doesn’t understand “int”
fromsymbol: doesn’t understand “float”

i put the HTML here: http://mikrogalleriet.net/test/arduino_website.html

#209503
Aug 4, 2011 at 10:22pm

Using the new URL everything works fine for me with the patch you posted. Try placing a message box or a [print] object after the [fromsymbol], maybe you have something grouping the messages in the wrong order.

#209504
Aug 4, 2011 at 10:22pm

Using the new URL everything works fine for me with the patch you posted. Try placing a message box or a [print] object after the [fromsymbol], maybe you have something grouping the messages in the wrong order.

#209507
Aug 5, 2011 at 6:51am

strange indeed…. its still not working for me?
i put a [print] in there. this is what my patch and max window looks like (attached)

[attachment=168261,2509]

#209505
Aug 5, 2011 at 6:51am

strange indeed…. its still not working for me?
i put a [print] in there. this is what my patch and max window looks like (attached)

[attachment=168261,2509]

Attachments:
  1. parsingerror.png
#209510
Aug 5, 2011 at 10:59am

ok so i just upgraded to the last version of max and now it works perfectly. thanks for all the help! (i was on 5.1.0 before)

#209506
Aug 5, 2011 at 10:59am

ok so i just upgraded to the last version of max and now it works perfectly. thanks for all the help! (i was on 5.1.0 before)

#209512

You must be logged in to reply to this topic.