On Wed, Feb 11, 2015 at 02:28:39PM +0100, Dirk Zimoch wrote:
On 09.02.2015 21:58, Kasemir, Kay wrote:
and then you need to be prepared to parse a response that looks like
HTTP/1.1 200 OK
Content-Type: text/html
Server: Whatever
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 97
.. the actual data..
Try regular expressions to fund the actual data in all the http noise.
See my example in the StreamDevice documentation:
http://epics.web.psi.ch/software/streamdevice/doc/tipsandtricks.html#web
get_title {
extrainput = ignore;
replyTimeout = 1000;
out "GET http://\$1\n\n";
in "%+.1/(?im)<title>(.*)<\/title>/";
}
Something like this can work with a device that always responds in a fixed
pattern. However, you should be aware that, in general, regular expressions
cannot be used to parse arbitrary HTML. A Stack Overflow article that
talks about this can be found here:
http://stackoverflow.com/questions/6751105/why-its-not-possible-to-use-regex-to-parse-html-xml-a-formal-explanation-in-la
A more entertaining, though less illuminating, explanation can be found here:
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
Hope this helps.
Bill Lavender