Chronological news titles

This flow retrieves Google news, extracts the title of only the top news, and stores it into a file every hour. When you access to /titles, you can see the news titles in chronological order.

The example output is as follows.

Golden Globes 2017: 10 things you need to know, from Meryl Streep to 'Hidden Fences'
The Golden Globes — what did it all mean for the Oscars?
In the Trump era, artists can be Jimmy Fallon or Donald Glover. Choose wisely.

The most important thing in this flow is to be composed of only the Node-RED core nodes without programming.

[{"id":"4de28fe1.5eb6e8","type":"html","z":"b73d115.2ff6df","name":"Extract titles","tag":"span.titletext","ret":"html","as":"single","x":572,"y":140,"wires":[["a88ce0cc.270e58"]]},{"id":"bb45d013.10636","type":"http request","z":"b73d115.2ff6df","name":"Google news","method":"GET","ret":"txt","url":"https://news.google.com/?ned=us","tls":"","x":390,"y":140,"wires":[["4de28fe1.5eb6e8"]]},{"id":"7bd141dc.481188","type":"inject","z":"b73d115.2ff6df","name":"Run every hour","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"x":193,"y":140,"wires":[["bb45d013.10636"]]},{"id":"a88ce0cc.270e58","type":"change","z":"b73d115.2ff6df","name":"Extract only the top title","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":786.5,"y":140,"wires":[["1c1ac3d1.2675cc"]]},{"id":"1c1ac3d1.2675cc","type":"template","z":"b73d115.2ff6df","name":"Add <br> tag","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{&payload}}<br>","x":521.5,"y":226,"wires":[["568604e2.32eb2c"]]},{"id":"568604e2.32eb2c","type":"file","z":"b73d115.2ff6df","name":"Store into news.txt","filename":"news.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","x":722.5,"y":226,"wires":[]},{"id":"10c57c25.574dac","type":"http in","z":"b73d115.2ff6df","name":"Request to titles","url":"/titles","method":"get","swaggerDoc":"","x":158.5,"y":420,"wires":[["26cedc26.84b4f4"]]},{"id":"26b7ea38.f39d46","type":"template","z":"b73d115.2ff6df","name":"Create HTML","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE HTML>\n<html>\n    <head>\n        <title>Chronological news titles</title>\n    </head>\n    <body>\n        {{&payload}}\n    </body>\n</html>","x":577.5,"y":420,"wires":[["72ba9e38.726c38"]]},{"id":"72ba9e38.726c38","type":"http response","z":"b73d115.2ff6df","name":"Response of titles","x":791.5,"y":420,"wires":[]},{"id":"26cedc26.84b4f4","type":"file in","z":"b73d115.2ff6df","name":"Open news.txt","filename":"news.txt","format":"utf8","x":379.5,"y":420,"wires":[["26b7ea38.f39d46"]]},{"id":"8c751dc4.3a5b1","type":"comment","z":"b73d115.2ff6df","name":"Retrieve Google news every hour and store the top title into a file","info":"","x":510.5,"y":77,"wires":[]},{"id":"86d952fe.1d2e38","type":"comment","z":"b73d115.2ff6df","name":"When accessed to /titles, retrieve top titles from a file and return them.","info":"","x":521,"y":355,"wires":[]}]
Kazuki-Nakanishi

Flow Info

created 5 months, 3 weeks ago

Node Types

Core
  • change (x1)
  • comment (x2)
  • file (x1)
  • file in (x1)
  • html (x1)
  • http in (x1)
  • http request (x1)
  • http response (x1)
  • inject (x1)
  • template (x2)

Tags

  • news
  • HTTP
  • file
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option