Http 节点说明

Http 节点说明

http请求是我们经常使用获取第三方数据的方式,但是系统提供的这个节点能设置的信息太少了,但是有些还是可以设置的,只是直接暴露给我们设置很少.

{"id":"68360605.862db8","type":"tab","label":"测试流程1","disabled":false,"info":""},{"id":"1208c95.0f2fa37","type":"inject","z":"68360605.862db8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":81,"y":201,"wires":"7133ce15.37d77"]]},{"id":"7a48e7c2.6d3098","type":"debug","z":"68360605.862db8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":480,"y":186,"wires":]},{"id":"7133ce15.37d77","type":"http request","z":"68360605.862db8","name":"","method":"GET","ret":"txt","url":"http://www.baidu.com","tls":"","x":243,"y":197,"wires":"7a48e7c2.6d3098"]]}]

设置 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":]}]

url 使用模板

这个使用模板和之前的差不多了,直接使用{{xxxx}} 来使用msg.xxxx, 例如:

http://xxx.com/{{xxxx}}
//例如msg.xxxx = 123,最终请求的地址如下
http://xxx.com/123

url中的参数使用模板

url参数中使用模板和之前的方式都有区别,使用的是{{{xxx}}},例如:

http://xxx.com?a={{{xxxx}}}
//例如msg.xxxx = 123,最终请求的地址如下
http://xxx.com?a=123

设置http header

这个是没有提供直接修改的方式的,需要在当前节点前面建一个新的function节点设置这些信息,其中:

  • msg.url 对应请求的url
  • msg.headers 对应请求的header
  • msg.payload 对应的是请求的内容

{"id":"68360605.862db8","type":"tab","label":"测试流程1","disabled":false,"info":""},{"id":"b9f006a1.130dc8","type":"inject","z":"68360605.862db8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":378,"y":322,"wires":"782a5f4b.3d6eb"]]},{"id":"d424058b.1fd3b8","type":"http request","z":"68360605.862db8","name":"baidu","method":"POST","ret":"txt","url":"http://www.baidu.com","tls":"","x":748,"y":322,"wires":"f2e5c3a0.73ddd"]]},{"id":"782a5f4b.3d6eb","type":"function","z":"68360605.862db8","name":"set payload and headers","func":"msg.payload = \"data to post\";\nmsg.headers = {};\nmsg.headers'X-Auth-User'] = 'mike';\nmsg.headers'X-Auth-Key'] = 'fred-key';\n\nreturn msg;","outputs":1,"noerr":0,"x":568,"y":322,"wires":"d424058b.1fd3b8"]]},{"id":"f2e5c3a0.73ddd","type":"debug","z":"68360605.862db8","name":"","active":true,"console":"false","complete":"false","x":948,"y":322,"wires":]}]

需要登录的网站要如何使用这个

同问 想用nodered登陆路由器获取页面信息

把登录帐号密码的网站的Cookie 获取了 放进header

结尾的流无法导入