Last active
March 29, 2018 11:25
-
-
Save ripiuk/b792eb347ab3a9969e45c29513992e42 to your computer and use it in GitHub Desktop.
A simple nsq publisher using requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
url = 'http://localhost:4151' | |
topic = 'is-hotel-active' | |
url = '{url}/pub?topic={topic}'.format(url=url, topic=topic) | |
rows = [{'hotel_id': '81', 'is_hotel_active': '0'}, | |
{'hotel_id': '23', 'is_hotel_active': '1'}, | |
{'hotel_id': '82', 'is_hotel_active': '1'}] | |
session = requests.Session() | |
for row in rows: | |
session.post(url=url, data=json.dumps(row)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment