Hey all!
A rather fresh (~1 year on/off) node-red user here! I'm having trouble parsing a webpage which includes Scandinavian letters like ä/ö.
Here's an example flow:
[{"id":"a02852a0.3a07","type":"tab","label":"Encoding Tests","disabled":false,"info":""},{"id":"ba38d1f4.0b2","type":"debug","z":"a02852a0.3a07","name":"Parsed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":900,"y":240,"wires":[]},{"id":"3d216b95.a0462c","type":"http request","z":"a02852a0.3a07","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":240,"wires":[["44e88e2.6e44ef"]]},{"id":"44e88e2.6e44ef","type":"html","z":"a02852a0.3a07","name":"get element","property":"payload","outproperty":"payload","tag":".tori_title","ret":"html","as":"single","x":730,"y":240,"wires":[["ba38d1f4.0b2"]]},{"id":"2bac3368.a6e15c","type":"inject","z":"a02852a0.3a07","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":240,"wires":[["d9494d1.7e55d3"]]},{"id":"d9494d1.7e55d3","type":"function","z":"a02852a0.3a07","name":"URL","func":"msg.payload = \"https://muusikoiden.net/tori/ilmoitus/1649213\"\n\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":240,"wires":[["3d216b95.a0462c"]]},{"id":"54040bdd.f1a7a4","type":"debug","z":"a02852a0.3a07","name":"Example","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":900,"y":80,"wires":[]},{"id":"d3a70029.6e347","type":"inject","z":"a02852a0.3a07","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":80,"wires":[["ac69c829.ec2388"]]},{"id":"ac69c829.ec2388","type":"function","z":"a02852a0.3a07","name":"Generate \"wanted\" response","func":"msg.payload = [\"<b>Myydään:</b> Doepfer Dark Energy II\"]\n\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":80,"wires":[["54040bdd.f1a7a4"]]},{"id":"47282f0f.c3322","type":"comment","z":"a02852a0.3a07","name":"Should be like this!","info":"","x":530,"y":40,"wires":[]},{"id":"a980b970.cebc2","type":"function","z":"a02852a0.3a07","name":"Encoding","func":"msg.payload = msg.payload.toString('iso-8859-15')\n\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":340,"wires":[[]]},{"id":"2f26623b.167b7e","type":"comment","z":"a02852a0.3a07","name":"Tried out encoding, didn't work","info":"","x":720,"y":300,"wires":[]},{"id":"19bf0ef.76b9c71","type":"comment","z":"a02852a0.3a07","name":"But gives out this..","info":"","x":530,"y":200,"wires":[]}]
In short, I'm trying to read some elements from a webpage using a combination of the HTTP Request, as well as the HTML parser nodes. At the moment, I'm able to get the right elements with the HTML parser, but some of characters don't display properly at the debug-window. I added an alternative branch to the flow to show how they should look like, and also to confirm that, at least in my node-red instance, the debugger should be able to display the letters correctly.
I'm always a little confused with this encoding and decoding stuff, so I figured that instead of banging my head against the wall by myself, maybe some of you kind folks at the forum could guide me!
Thanks a lot for your time!