HTTPリクエストノードのURLを動的に設定したい。
HTTP Request
ノードのURLプロパティをセットします。
[{"id":"b36aa30.3a7276","type":"http request","z":"c9a81b70.8abed8","name":"","method":"GET","ret":"txt","url":"","x":470,"y":300,"wires":[["1ef9987c.956c78"]]},{"id":"11167f67.5d5031","type":"inject","z":"c9a81b70.8abed8","name":"cars on craigslist","topic":"","payload":"http://vancouver.craigslist.org/search/sss?format=rss&query=cars","payloadType":"str","repeat":"","crontab":"","once":false,"x":140,"y":300,"wires":[["70154cd4.de1444"]]},{"id":"70154cd4.de1444","type":"change","z":"c9a81b70.8abed8","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":300,"wires":[["b36aa30.3a7276"]]},{"id":"1ef9987c.956c78","type":"debug","z":"c9a81b70.8abed8","name":"","active":true,"console":"false","complete":"false","x":630,"y":300,"wires":[]}]
Inject
ノードでURLとなる文字列を生成し、
Change
ノードで msg.URL
プロパティにセットしています。
このフローではURLは次のようにセットされます:
http://vancouver.craigslist.org/search/sss?format=rss&query=cars
Craigslistというサイトの、バンクーバーで売りに出されている車の情報をRSSで返します。 次のようなXMLの内容がデバッグウィンドウに表示されます:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:enc="http://purl.oclc.org/net/rss_2.0/enc#"
xmlns:ev="http://purl.org/rss/1.0/modules/event/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
xmlns:admin="http://webns.net/mvcb/"
>
<channel rdf:about="https://vancouver.craigslist.ca/search/sss?format=rss&query=cars">
<title>craigslist vancouver, BC | for sale search "cars"</title>
<link>https://vancouver.craigslist.ca/search/sss?query=cars</link>
<description></description>
<dc:language>en-us</dc:language>
<dc:rights>copyright 2017 craiglist</dc:rights>
<dc:publisher>[email protected]</dc:publisher>
<dc:creator>[email protected]</dc:creator>
<dc:source>https://vancouver...
RSSの内容をXMLに変換するために、HTTP Request
の後に
XML
も追加できます。
RSSの内容はアクセスしやすいようにJavaScriptオブジェクトで返されます。
Node-RED: Low-code programming for event-driven applications.
Copyright OpenJS Foundation and Node-RED contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy